-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from meta-panic/feature/debug-header-autotests
Feature/debug header autotests
- Loading branch information
Showing
5 changed files
with
67 additions
and
1 deletion.
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
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,46 @@ | ||
import { test as base, expect, Page } from '@playwright/test'; | ||
|
||
type CustomFixtures = { | ||
page: Page; | ||
consoleErrors: string[]; | ||
}; | ||
|
||
export const test = base.extend<CustomFixtures>({ | ||
consoleErrors: async ({}, use) => { | ||
const errors: string[] = []; | ||
await use(errors); | ||
}, | ||
|
||
page: async ({ page, consoleErrors }, use) => { | ||
// Catch errors in console | ||
page.on('console', msg => { | ||
if (msg.type() === 'error') { | ||
consoleErrors.push(msg.text()); | ||
} | ||
}); | ||
|
||
// Catch unhandled exceptions on page | ||
page.on('pageerror', error => { | ||
consoleErrors.push(error.message); | ||
}); | ||
|
||
// Add custom header to all requests | ||
page.route('**', route => { | ||
const headers = { | ||
...route.request().headers(), | ||
'Debug-Header': '[0_o] Hello from playwright autotests' | ||
}; | ||
route.continue({ headers }); | ||
}); | ||
|
||
await use(page); | ||
} | ||
}); | ||
|
||
// Existing console errors check | ||
export const checkConsoleErrors = () => { | ||
test('check console errors', async ({ consoleErrors, page }) => { | ||
await page.waitForLoadState('networkidle'); | ||
expect(consoleErrors, 'Found errors on the page').toHaveLength(0); | ||
}); | ||
}; |
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
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,3 +1,7 @@ | ||
headers { | ||
Debug-Header: [0_o] Hello from bruno autotests | ||
} | ||
|
||
docs { | ||
API Client - https://github.com/usebruno/bruno | ||
} |
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