伙计们。当我运行测试时,这个错误会随机出现。
Chromium打开了一个标签,但很快自动关闭了,然后就出现了这个错误。
我在谷歌上没有找到答案。
错误是随机发生的。
运行多个测试的错误出现概率更高。
它不会全部失败,通常最后一次测试会成功。
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'
};