-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
we will now be using the k6 example website to reduce test flakiness
- Loading branch information
1 parent
6ca8ff0
commit b362c65
Showing
4 changed files
with
48 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
import pw from 'k6/x/playwright'; | ||
|
||
export default function () { | ||
pw.connect("http://localhost:9222") | ||
pw.goto("https://www.github.com/", {waitUntil: 'networkidle'}) | ||
pw.waitForSelector(".search-input", {state: 'visible'}) | ||
pw.kill() | ||
} | ||
pw.connect('http://localhost:9222'); | ||
try { | ||
pw.goto('https://test.k6.io/', { waitUntil: 'networkidle' }); | ||
pw.waitForSelector("input[name='login']", { state: 'visible' }); | ||
} catch (err) { | ||
console.log(err); | ||
} finally { | ||
pw.kill(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
import pw from 'k6/x/playwright'; | ||
|
||
export default function () { | ||
pw.launch({headless: false}) | ||
pw.newPage() | ||
pw.goto("https://www.github.com/", { waitUntil: 'networkidle'}) | ||
pw.waitForSelector(".search-input", {state: 'visible'}) | ||
pw.kill() | ||
} | ||
try { | ||
pw.launch({ headless: false }); | ||
pw.newPage(); | ||
pw.goto('https://test.k6.io/', { waitUntil: 'networkidle' }); | ||
pw.waitForSelector("input[name='login']", { state: 'visible' }); | ||
} catch (err) { | ||
console.log(err); | ||
} finally { | ||
pw.kill(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
import pw from 'k6/x/playwright'; | ||
|
||
export default function () { | ||
pw.launch() | ||
pw.newPage() | ||
pw.goto("https://www.github.com/") | ||
pw.waitForSelector(".search-input", {state: 'visible'}) | ||
pw.type(".search-input", "how to measure real user metrics with the xk6-playwright extension for k6?") | ||
try { | ||
pw.launch() | ||
pw.newPage() | ||
pw.goto('https://test.k6.io/', { waitUntil: 'networkidle' }); | ||
pw.waitForSelector("input[name='login']", { state: 'visible' }); | ||
pw.type("input[name='login']", "admin") | ||
|
||
//print out real user metrics of the google search page | ||
console.log(`First Paint: ${pw.firstPaint()}ms`) | ||
console.log(`First Contentful Paint: ${pw.firstContentfulPaint()}ms`) | ||
console.log(`Time to Minimally Interactive: ${pw.timeToMinimallyInteractive()}ms`) | ||
console.log(`First Input Delay: ${pw.firstInputDelay()}ms`) | ||
|
||
pw.kill() | ||
//print out real user metrics of the google search page | ||
console.log(`First Paint: ${pw.firstPaint()}ms`) | ||
console.log(`First Contentful Paint: ${pw.firstContentfulPaint()}ms`) | ||
console.log(`Time to Minimally Interactive: ${pw.timeToMinimallyInteractive()}ms`) | ||
console.log(`First Input Delay: ${pw.firstInputDelay()}ms`) | ||
} catch (err) { | ||
console.log(err); | ||
} finally { | ||
pw.kill(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
import pw from 'k6/x/playwright'; | ||
|
||
export const options = { | ||
vus: 1, | ||
}; | ||
|
||
export default function () { | ||
pw.launch() | ||
pw.newPage() | ||
pw.goto("https://www.github.com/", {waitUntil: 'networkidle'}) | ||
pw.waitForSelector(".search-input", {state: 'visible'}) | ||
pw.kill() | ||
} | ||
try { | ||
pw.launch(); | ||
pw.newPage(); | ||
pw.goto('https://test.k6.io/', { waitUntil: 'networkidle' }); | ||
pw.waitForSelector("input[name='login']", { state: 'visible' }); | ||
} catch (err) { | ||
console.log(err); | ||
} finally { | ||
pw.kill(); | ||
} | ||
} |