[QUESTION] how do I properly configure with it,jestPlaywrightConfig()..
See original GitHub issueI’m trying to pass jetPlaywrightConfig in a test, however I don’t seem to get it to work.
This is my test:
import { JestPlaywrightConfig } from 'jest-playwright-preset';
describe('TEST 001', () => {
const config: JestPlaywrightConfig = {
devices: ['iPhone 11'],
contextOptions: { locale: 'nl-NL' },
exitOnPageError: true, // required
browsers: ['chromium'], // required
collectCoverage: false, // required
}
// without the required I get a property missing error
it.jestPlaywrightConfig(config, 'WITH CONFIG', async () => {
await page.goto('http://google.com');
await page.waitForTimeout(10000);
}
}
Expected: the test launches in a browser sized to iPhone 11 with nl-NL locale. Actual: when I run the test I see a browser open, then a second. Both have the default size. The test is executed inside the first browser.
This is my jest.config.js:
module.exports = {
verbose: true,
preset: 'jest-playwright-preset',
transform: {
'^.+\\.ts$': 'ts-jest',
},
testTimeout: 60000,
testRunner: 'jasmine2',
globalSetup: './globalSetup.js',
setupFilesAfterEnv: [
"jest-allure/dist/setup"
],
testEnvironmentOptions: {
'jest-playwright': {
launchOptions: {
headless: false
}
}
},
}
When I put the device and locale option inside the jest.config then I see the test run properly in a iPhone 11 sized browser.
Am I missing something in the way I use it.jestPlaywrightConfig()? Thank you.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Jest & Playwright Preset Configuration | Playwright - Part 18
Very important concept! Please watchfully.In this video. we are going to config the jest & playwright preset.It will help us to integrate ...
Read more >Configuring Jest
Jest will run .mjs and .js files with nearest package.json 's type field set to module as ECMAScript Modules.
Read more >First steps with end-to-end testing using jest + playwright ...
We will create a base repository with Playwright and JestJS and write a basic test which will: Load the blog page,; Check if...
Read more >Answers to All The Top Questions For Playwright Testing
All the top answers to your favorite questions on the hottest new testing framework from Microsoft, Playwright.
Read more >Using Jest with Playwright
The way how you should integrate Playwright into your project depends on your needs. Currently there two common ways of doing that. Either...
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
@ychaudhari it should be ok in your case. The only thing that you should use provided
page
instance, otherwise it will tests global instance:Also you can try to use
jestPlaywrightDebug
method. It will run your test with this params:@mmarkelov Is it possible to use a different launchOption with this method? I’m using playwright 1.8.0. I want to run a particular test in headful mode but rest of the suite in headless mode, I tried following
However, test still picks up headless config from
jest.config.ts
file and runs the test in headless modeIs it possible to have a different launchOption with this method? or is the browser already lauched by the time it reaches to the test (i.e. ‘it’) also, is there a way to apply separate config to describe/beforeEach blocks?