Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore(test): test cleanup (#1198)

Yury Semikhatsky4556513c2a5c
diff --git a/test/browsercontext.spec.js b/test/browsercontext.spec.js
index 35b5506a76..43ea2999e8 100644
--- a/test/browsercontext.spec.js
+++ b/test/browsercontext.spec.js
@@ -304,6 +304,14 @@ module.exports.describe = function({testRunner, expect, playwright, CHROMIUM, FF
expect(allPages).toContain(second);
await context.close();
});
+ it('should close all belonging pages once closing context', async function({browser}) {
+ const context = await browser.newContext();
+ await context.newPage();
+ expect((await context.pages()).length).toBe(1);
+
+ await context.close();
+ expect((await context.pages()).length).toBe(0);
+ });
});
describe('BrowserContext.exposeFunction', () => {
@@ -375,7 +383,7 @@ module.exports.describe = function({testRunner, expect, playwright, CHROMIUM, FF
expect(allPages).not.toContain(otherPage);
await context.close();
});
- it('should not report uninitialized pages', async({browser, server}) => {
+ it('should report initialized pages', async({browser, server}) => {
const context = await browser.newContext();
const pagePromise = new Promise(fulfill => context.once('page', async event => fulfill(await event.page())));
context.newPage();
@@ -390,7 +398,7 @@ module.exports.describe = function({testRunner, expect, playwright, CHROMIUM, FF
await evaluatePromise;
await context.close();
});
- it('should not crash while redirecting if original request was missed', async({browser, server}) => {
+ it('should not crash while redirecting of original request was missed', async({browser, server}) => {
const context = await browser.newContext();
const page = await context.newPage();
let serverResponse = null;
@@ -425,14 +433,6 @@ module.exports.describe = function({testRunner, expect, playwright, CHROMIUM, FF
expect(await page.opener()).toBe(null);
await context.close();
});
- it('should close all belonging targets once closing context', async function({browser}) {
- const context = await browser.newContext();
- await context.newPage();
- expect((await context.pages()).length).toBe(1);
-
- await context.close();
- expect((await context.pages()).length).toBe(0);
- });
it('should fire page lifecycle events', async function({browser, server}) {
const context = await browser.newContext();
const events = [];