Skip to content

Commit

Permalink
test: add debug variable
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jun 25, 2024
1 parent dd2abba commit c22cbee
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ concurrency:

env:
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/.cache/ms-playwright
VITEST_PW_DEBUG: true

jobs:
lint:
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/client/tester/tester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async function runTests(files: string[]) {
preparedData = await prepareTestEnvironment(files)
}
catch (error: any) {
debug('data cannot be loaded because it threw an error', error.stack || error.message)
debug('runner cannot be loaded because it threw an error', error.stack || error.message)
await client.rpc.onUnhandledError(serializeError(error), 'Preload Error')
done(files)
return
Expand Down
12 changes: 12 additions & 0 deletions packages/browser/src/node/providers/playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@ export class PlaywrightBrowserProvider implements BrowserProvider {
const page = await context.newPage()
this.pages.set(contextId, page)

if (process.env.VITEST_PW_DEBUG) {
page.on('requestfailed', (request) => {
console.error(
request.resourceType(),
'request failed for',
request.url(),
'url:',
request.failure()?.errorText,
)
})
}

return page
}

Expand Down

0 comments on commit c22cbee

Please sign in to comment.