Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resetContext() fails to close a page. #612

Closed
ychaudhari opened this issue Mar 5, 2021 · 0 comments · Fixed by #613
Closed

resetContext() fails to close a page. #612

ychaudhari opened this issue Mar 5, 2021 · 0 comments · Fixed by #613
Labels
bug Something isn't working

Comments

@ychaudhari
Copy link

ychaudhari commented Mar 5, 2021

Describe the bug
jestPlaywright.resetContext(); fails to close a page.

To Reproduce
Run following test with DEBUG=pw:api

describe('Testing', () => {
  beforeEach(async () => {
    await jestPlaywright.resetContext();
  });
  it('test1', async () => {
    await page.goto('http://www.google.com');
  });
});

Expected behavior
No fails in the logs

Actual behavior
Shows following error in logs

  pw:api => page.close started +4ms
  pw:api <= page.close failed +7ms

Full log

  pw:api => browserType.connect started +0ms
  pw:api <= browserType.connect succeeded +25ms
  pw:api => browser.newContext started +5ms
  pw:api <= browser.newContext succeeded +20ms
  pw:api => browserContext.newPage started +6ms
  pw:api <= browserContext.newPage succeeded +143ms
  pw:api => browserContext.close started +4s
  pw:api <= browserContext.close succeeded +14ms
  pw:api => browser.newContext started +4ms
  pw:api <= browser.newContext succeeded +8ms
  pw:api => page.close started +4ms
  pw:api <= page.close failed +7ms
  pw:api => browserContext.newPage started +5ms
  pw:api <= browserContext.newPage succeeded +95ms
  pw:api => page.goto started +5ms
  pw:api navigating to "http://www.google.com", waiting until "load" +7ms
  pw:api   navigated to "https://www.google.com/?gws_rd=ssl" +631ms
  pw:api   navigated to "https://www.google.com/?gws_rd=ssl" +226ms
  pw:api   "domcontentloaded" event fired +4ms
  pw:api   "load" event fired +540ms
  pw:api <= page.goto succeeded +5ms
  pw:api => browser.close started +8ms
  pw:api <= browser.close succeeded +8ms
 PASS   browser: chromium  tests/one.test.ts (5.595 s)

Screenshots
N/A

Desktop (please complete the following information):

  • OS: Windows
  • Playwright version 1.9.1
  • jest-playwright version 1.4.7

Jest configuration (Either in the package.json > jest or in the jest.config.js):

import type { Config } from '@jest/types';

export default async (): Promise<Config.InitialOptions> => {
 return {
   verbose: true,
   setupFilesAfterEnv: ['./jest.setup.ts', 'expect-playwright'],
   preset: 'jest-playwright-preset',
   testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[tj]s?(x)'],
   testPathIgnorePatterns: ['/node_modules/'],
   transform: {
     '^.+\\.ts?$': 'ts-jest',
   },
   testEnvironment: './CustomEnvironment.js',
 };
};

jest-playwright.config.js

module.exports = {
  browsers: ['chromium'],
  connectOptions: {},
  contextOptions: {},
  launchOptions: {
    headless: true,
  },
};

Additional context
N/A

Question
What is the right way to reset browser/context/pages after/before use so that we do not get any fails in the logs and we do not leave un-used objects in the memory after the test?

@ychaudhari ychaudhari changed the title jestPlaywright.resetContext() fails to close a page. resetContext() fails to close a page. Mar 5, 2021
@mmarkelov mmarkelov added the bug Something isn't working label Mar 5, 2021
mmarkelov added a commit that referenced this issue Mar 5, 2021
mmarkelov added a commit that referenced this issue Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants