jest-puppeteer: TypeError: Cannot read property 'browserContext' of undefined

573 views Asked by At

guys. This error will random appear when I running tests.

Chromium opened a tab, but soon automatic shut itself down quickly, then this error appeared.

I didn't find the answer on the google.

  1. The error is happens randomly.

  2. Error appear probability is higher of multiple tests running.

  3. It won't all fail, often the last test will succeed.

 FAIL  __tests__/login/login.test.js
  ● Test suite failed to run

    TypeError: Cannot read property 'browserContext' of undefined

      at PuppeteerEnvironment.teardown (node_modules/jest-environment-puppeteer/lib/PuppeteerEnvironment.js:161:25)

 FAIL  __tests__/homepage/homepage.test.js
  ● Test suite failed to run

    TypeError: Cannot read property 'browserContext' of undefined

      at PuppeteerEnvironment.teardown (node_modules/jest-environment-puppeteer/lib/PuppeteerEnvironment.js:161:25)

 FAIL  __tests__/google.test.js
  ● Test suite failed to run

    TypeError: Cannot read property 'browserContext' of undefined

      at PuppeteerEnvironment.teardown (node_modules/jest-environment-puppeteer/lib/PuppeteerEnvironment.js:161:25)

jest-puppeteer.config.js

module.exports = {
  launch: {
    headless: !searchArgv('head'),
    devtools: false,
    // slowMo: 100,
    defaultViewport: {
      width: 1440,
      height: 1080
    },
  },
  browser: 'chromium',
  browserContext: 'default'
};
0

There are 0 answers