Using a custom environment per the docs give: "TypeError: Cannot destructure property 'collectCoverage' of 'this._jestPlaywrightConfig' as it is undefined."
See original GitHub issueDescribe the bug
Using a custom environment per the docs give: TypeError: Cannot destructure property 'collectCoverage' of 'this._jestPlaywrightConfig' as it is undefined.
The custom environment has been configured according to https://github.com/playwright-community/jest-playwright#usage-with-jest-circus
To Reproduce Add a custom environment according to https://github.com/playwright-community/jest-playwright#usage-with-jest-circus
Expected behavior It should work.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: Ubuntu 18.04
- Playwright version: 1.5.1
- jest-playwright version: 1.3.1
Jest configuration (Either in the package.json > jest or in the jest.config.js
):
module.exports = {
// Test sequencers cannot exist in projects, only in global config
testSequencer: './tests/e2e/util/jestSequencer.js',
projects: [
{
displayName: 'E2E',
rootDir: 'tests/e2e',
testEnvironment: '<rootDir>/util/CustomEnvironment.js',
testRunner: 'jest-circus/runner',
runner: '<rootDir>/util/serialJestRunner.js',
preset: 'jest-playwright-preset',
globals: {
TEST_URL: testUrl,
},
setupFilesAfterEnv: ['<rootDir>/jest.setup.js', 'expect-playwright'],
globalSetup: '<rootDir>/util/globalSetup.js',
globalTeardown: '<rootDir>/util/globalTeardown.js',
},
],
};
Additional context This is the custom environment:
class CustomEnvironment extends PlaywrightEnvironment {
constructor(config) {
super(config);
this.config = config;
}
async setup() {
await super.setup();
this.allure = new Allure();
this.allure.setOptions({
targetDir: `${this.config.rootDir}/allure_results`,
});
}
async handleTestEvent(event) {
switch (event.name) {
case 'start_describe_definition':
this.allure.startSuite(event.blockName);
break;
case 'test_start':
this.allure.startCase(event.test.name);
break;
case 'test_done': {
if (event.test.errors.length > 0) {
const screenshot = await this.global.page.screenshot();
this.allure.addAttachment('screenshot', screenshot, 'image/png');
this.allure.endCase('failed', event.error);
} else this.allure.endCase('passed');
break;
}
case 'run_finish': {
this.allure.endSuite();
break;
}
default:
break;
}
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Jest with Vue3 ERROR: Cannot destructure property 'config' of ...
On the project, I used Vue3, Vite, Typescript and testing tool Jest. I found only 1 solution to fix this. I have the...
Read more >jest-playwright-preset - npm Package Health Analysis - Snyk
For more information about how to use this package see README ... A custom path can be specified to the jest-playwright.config.js file within...
Read more >jest-playwright-preset: Versions - Openbase
Full version history for jest-playwright-preset including change logs. ... Fix TypeError: Cannot destructure property name of 'undefined' or 'null'.
Read more >Cannot destructure property 'config' of +'cacheKeyOptions' as ...
Cannot destructure property 'config' of +'cacheKeyOptions' as it is undefined. ... You can check if you're using the latest version with: npm outdated...
Read more >Using Jest with Playwright
Having a test runner like Jest configured has a lot of benefits instead of writing your tests from scratch. It gives you out...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@thernstig yeah! That make sense. I put it here
That made it, thanks! Maybe there should be a note about this in the README?