This is randomly happening for me only on GitLab CI, when I run tests locally everything is fine 100% of the times.
I'm using this config
e2e:
stage: e2e
image: mcr.microsoft.com/playwright:focal
script:
- npm run test:e2e
"test:e2e": "DEBUG=pw:api playwright test e2e",
const config: PlaywrightTestConfig = {
workers: 1,
retries: 0,
timeout: 150000,
globalSetup: './globalSetup',
}
In my global setup I signup 3 different type of users and save their 3 browser context into json storage.
Something like this
async function globalSetup() {
const browser = await chromium.launch({
slowMo: 2000,
})
const baseContext = await browser.newContext({
baseURL: frontendBaseUrl,
})
// do stuff
await baseContext.context().storageState({ path: 'baseStorageState.json' })
const ownerContext = await browser.newContext({
baseURL: frontendBaseUrl,
})
// do stuff
await ownerPage.context().storageState({ path: 'ownerStorageState.json' })
// repeat
await browser.close()
}
Then I have a test.describe.serial("3 roles", ...) that is testing operations on the 3 roles. I know serial is not advised but I need to because I have a use case where the first user has to invite others in their "workspace" and the other tests can only start when the invite has been created and then consumed.
test.describe.serial('Console', () => {
let inviteLinkAdmin: string
let inviteLinkViewer: string
let browser: ChromiumBrowser
test.beforeAll(async () => {
browser = await chromium.launch({
slowMo: 500,
})
})
test.afterAll(async () => {
await browser.close()
})
test('OWNER ROLE', async () => {
const context = await browser.newContext({
storageState: 'ownerStorageState.json',
baseURL: frontendBaseUrl,
})
// do stuff
})
test('VIEWER ROLE', async () => {
const context = await browser.newContext({
storageState: 'viewerStorageState.json',
baseURL: frontendBaseUrl,
})
// do stuff
})

As you can see I have DEBUG=pw:api enabled but it still doesn't tell me exactly why browser.newContext failed, is there a way to know?
This is randomly happening for me only on GitLab CI, when I run tests locally everything is fine 100% of the times.
I'm using this config
In my global setup I signup 3 different type of users and save their 3 browser context into json storage.
Something like this
Then I have a
test.describe.serial("3 roles", ...)that is testing operations on the 3 roles. I know serial is not advised but I need to because I have a use case where the first user has to invite others in their "workspace" and the other tests can only start when the invite has been created and then consumed.As you can see I have
DEBUG=pw:apienabled but it still doesn't tell me exactly whybrowser.newContextfailed, is there a way to know?