-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92297d8
commit 3bc107f
Showing
1 changed file
with
50 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { check } from 'k6'; | ||
import { browser } from 'k6/x/browser'; | ||
|
||
export const options = { | ||
scenarios: { | ||
ui: { | ||
executor: 'shared-iterations', | ||
options: { | ||
browser: { | ||
type: 'chromium', | ||
}, | ||
}, | ||
}, | ||
}, | ||
thresholds: { | ||
checks: ["rate==1.0"] | ||
} | ||
}; | ||
|
||
export default async function () { | ||
const page = browser.newPage(); | ||
const context = page.context(); | ||
|
||
try { | ||
// get cookies from the browser context | ||
check(context.cookies().length, { | ||
'initial number of cookies should be zero': n => n === 0, | ||
}); | ||
|
||
// add some cookies to the browser context | ||
context.addCookies([{name: 'testcookie', value: '1', sameSite: 'Strict', domain: '127.0.0.1', path: '/'}]); | ||
context.addCookies([{name: 'testcookie2', value: '2', sameSite: 'Lax', domain: '127.0.0.1', path: '/'}]); | ||
|
||
check(context.cookies().length, { | ||
'number of cookies should be 2': n => n === 2, | ||
}); | ||
|
||
const cookies = context.cookies(); | ||
check(cookies[0], { | ||
'cookie 1 name should be testcookie': c => c.name === 'testcookie', | ||
'cookie 1 value should be 1': c => c.value === '1', | ||
}); | ||
check(cookies[1], { | ||
'cookie 2 name should be testcookie2': c => c.name === 'testcookie2', | ||
'cookie 2 value should be 2': c => c.value === '2', | ||
}); | ||
} finally { | ||
page.close(); | ||
} | ||
} |