fix(playwright): raise any pageerror, purpose is to stops immediatly on a bundle issue
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { test, expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
import { goToLoginPage, loginAsAdmin, TEST_ADMIN } from './helpers';
|
import { test, goToLoginPage, loginAsAdmin, TEST_ADMIN } from './helpers';
|
||||||
|
|
||||||
test('has OxiCloud title', async ({ page }) => {
|
test('has OxiCloud title', async ({ page }) => {
|
||||||
await page.goto('/');
|
await page.goto('/');
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as fs from 'fs/promises';
|
import * as fs from 'fs/promises';
|
||||||
import { test, expect, Page } from '@playwright/test';
|
import { expect, Page } from '@playwright/test';
|
||||||
import { loginAsAdmin } from './helpers';
|
import { test, loginAsAdmin } from './helpers';
|
||||||
|
|
||||||
const FIXTURES = path.join(__dirname, '../../fixtures');
|
const FIXTURES = path.join(__dirname, '../../fixtures');
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,25 @@
|
|||||||
import { Page, expect } from '@playwright/test';
|
import { test as base, Page, expect } from '@playwright/test';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extended `test` fixture that fails on any unhandled browser-side JavaScript
|
||||||
|
* error (SyntaxError, ReferenceError, uncaught promise rejections, etc.).
|
||||||
|
*
|
||||||
|
* Import `test` from this module instead of `@playwright/test` so every spec
|
||||||
|
* gets the listener automatically without per-file boilerplate.
|
||||||
|
*/
|
||||||
|
export const test = base.extend<object>({
|
||||||
|
page: async ({ page }, use) => {
|
||||||
|
const jsErrors: Error[] = [];
|
||||||
|
page.on('pageerror', (err) => jsErrors.push(err));
|
||||||
|
await use(page);
|
||||||
|
if (jsErrors.length > 0) {
|
||||||
|
throw new Error(
|
||||||
|
`${jsErrors.length} unhandled JS error(s) on page:\n` +
|
||||||
|
jsErrors.map((e) => ` • ${e.message}`).join('\n')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export const TEST_ADMIN = {
|
export const TEST_ADMIN = {
|
||||||
username: 'admin',
|
username: 'admin',
|
||||||
@@ -38,7 +59,11 @@ export async function goToLoginPage(page: Page) {
|
|||||||
await page.goto('/');
|
await page.goto('/');
|
||||||
|
|
||||||
// Both panels start with .hidden — wait for JS to reveal one.
|
// Both panels start with .hidden — wait for JS to reveal one.
|
||||||
await page.waitForSelector('#language-panel:not(.hidden), #login-panel:not(.hidden)');
|
// Use expect() (5 s default) rather than waitForSelector() (30 s) so a JS
|
||||||
|
// crash fails fast instead of hanging for the full test timeout.
|
||||||
|
await expect(
|
||||||
|
page.locator('#language-panel:not(.hidden), #login-panel:not(.hidden)').first()
|
||||||
|
).toBeAttached();
|
||||||
|
|
||||||
if (await page.locator('#language-panel').isVisible()) {
|
if (await page.locator('#language-panel').isVisible()) {
|
||||||
await page.locator('#language-continue').click();
|
await page.locator('#language-continue').click();
|
||||||
|
|||||||
Reference in New Issue
Block a user