playwright-fluent
Version:
Fluent API around playwright
37 lines (36 loc) • 1.34 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const path = tslib_1.__importStar(require("path"));
const SUT = tslib_1.__importStar(require("../../playwright-fluent"));
describe('Playwright Fluent - recordPageErrors', () => {
let p;
beforeEach(() => {
p = new SUT.PlaywrightFluent();
});
afterEach(async () => {
await p.close();
});
test('should record uncaught exception and console.error logs', async () => {
// Given
const url = `file:${path.join(__dirname, 'record-page-errors.test.html')}`;
// When
await p
.withBrowser('chromium')
.withOptions({ headless: true })
.recordPageErrors()
.navigateTo(url);
await p.waitForStabilityOf(async () => p.getPageErrors().length, {
stabilityInMilliseconds: 1000,
});
// Then
const result = p.getPageErrors();
expect(result.length).toBe(4);
expect(result[0].message).toContain('console error');
expect(result[1].message).toContain('Error#1');
expect(result[2].message).toContain('Error#2');
expect(result[3].message).toContain('Error#3');
p.clearPageErrors();
expect(p.getPageErrors().length).toBe(0);
});
});
;