Easier debugging / test-specific configurations
See original GitHub issueIs your feature request related to a problem? Please describe.
I typically run all tests headless, but I often have failing tests that that require visually inspecting the page. Currently, this involves the following:
- Find my
jest-playwright.config.js
file - Modify my
browsers
to include only one browser (since I generally don’t need to visually inspect in multiple browsers) - Modify my
launchOptions
to setheadless:false
and occasionallydevtools:true
Once the test passes, I then have to undo all of the changes made above.
What would greatly speed up this process is a way to launch a single test in non-headless mode, possibly with devtools enabled, for one-or-more browsers and/or devices. Ideally, this would be as quick as adding .only
or .skip
to a test, although this would obviously take some pre-configuration.
Describe the solution you’d like
The verbose-but-flexible way would be to allow passing configuration options with each test. Using the existing jestPlaywright.skip
implementation as inspiration, perhaps something like this could work:
jestPlaywright.config({
browser: 'chromium',
launchOptions: {
headless: false,
devtools: true,
}
}, () => {
// Tests...
})
This could be made less obnoxious by storing the non-headless/debug configuration separately and passing it to the .config()
method:
const jestPlaywrightDebugConfig = {
browser: 'chromium',
launchOptions: {
headless: false,
devtools: true,
}
};
jestPlaywright.config(jestPlaywrightDebugConfig, () => {
// Tests...
})
Better yet, the non-headless/debug configuration could be set in jest-playwright.config.js
, allowing a much simpler .debug()
method to be used without passing additional parameters:
// jest-playwrite.config.js
module.exports = {
browsers: [
'chromium',
'firefox',
'webkit',
],
debugOptions: {
browsers: [
'chromium'
],
launchOptions: {
headless: false,
devtools: true
}
}
};
// my.test.js
jestPlaywright.debug(() => {
// Tests...
})
Issue Analytics
- State:
- Created 3 years ago
- Comments:20 (18 by maintainers)
@jhildenbiddle thank you for your suggestion. Seems like that it can be very helpful. I’ll take it
@mmarkelov, @jhildenbiddle Hey mates, sorry for interrupting your discussion, but to me the entire flow looks a bit broken. I mean, you should not modify your code to enter debug mode. You should probably modify it when you actually want to fix it.
Saying that, implementing most of the API presented here is a bit overkill to me.
Let me explain how could one address the actual issue in the OP.
Instead of keeping all of your test run parameters in
jest-playwright.config.js
, you should keep some/most of them in some JSON file, which will present your environment.And you can read that JSON in your
jest-playwright.config.js
, and set it’s values as env vars, but only those that are not yet defined:This approach gives you an ability to set env vars for you particular test run, and run your tests with no code modification.
So far I made zero changes to run my particular test with particular parameters. And you can parametrize your setup up to your needs.
Again, if you want to skip a test - can’t you use Jest’s
it.skip()
, andit.only()
for selected run? Why you introduce new hooks in this runner?And in order to inject a breakpoint, since you mentioned VSCode - it has super nice JavaScript Debug Terminal, which attaches to any Node code/process, and you can place your breakpoints directly in your test sources. No need for explicit
debugger
statements or similar.What do you think?