Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jestPlaywright.debug() support in Jest-circus #66

Closed
thernstig opened this issue Mar 11, 2020 · 5 comments
Closed

jestPlaywright.debug() support in Jest-circus #66

thernstig opened this issue Mar 11, 2020 · 5 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@thernstig
Copy link
Contributor

I'm going to be honest to say I've not investigated this yet, but seeing as jest-playwright's grandfather is jest-puppeteer, I expect this is not supported.

For reference for this issue, see argos-ci/jest-puppeteer#255

I wonder if there any plans to support jest-circus. While jest-circus works kinda fine out of the box, I noticed that jestPlaywright.debug() does not really work as expected.

@mmarkelov
Copy link
Member

@thernstig according to that issue, jestPlaywright.debug() is exactly the same as jestPuppeteer.debug(), which is hacky solution. And as for me we shouldn't use it, but we need to find out solution to stop test execution. I just made some research on it, but didn't find solution :(
Some related issues:

@mmarkelov mmarkelov added enhancement New feature or request help wanted Extra attention is needed labels Mar 11, 2020
@thernstig
Copy link
Contributor Author

Ok, that's good news though that you are looking into better alternatives. Will happily test it once in place.

@mmarkelov
Copy link
Member

Made some research on it. Seems like it is useless for jest 25: https://github.com/mmarkelov/jest-playwright/blob/6db32bf6ad8416af043e9c93eebba4e24e3be1f9/src/PlaywrightEnvironment.ts#L73-L83
As workaround you can set timeout in beforeAll, cause I just can't find way to set it in NodeEnvironment:

        beforeAll(async () => {
		jest.setTimeout(100000)
	})

        it('your test, async () => {
		await jestPlaywright.debug()
	})

I'm thinking about adding some debug script for this. Something like this:
jest-playwright --debug
that will just setup extra variables under hood:
jest --testRunner='jest-circus/runner' --testTimeout=100000 --detectOpenHandles

Also some logic may be added in Env:

    async handleTestEvent(event) {
        if (event.name === 'test_fn_failure') {
            await this.global.jestPlaywright.debug();
        }
    }

What do you think about it?

@thernstig
Copy link
Contributor Author

Is there no way to set jest.setTimeout() in the constructor in your environment (that extends NodeEnvironment?)

Our project is currently not using jest-playwright but only using Jest directly. The reason for this is that we are multiple developers, and we use jest for both unit, integration and e2e tests. Adding the overhead of users to learn another CLI tool is not an ideal solution for us, so we try to stick with making jest work for all scenarios. Is there a need of the jest-playwright that jest does not support? (Just guessing as well, but aren't you also loosing all other config options for jest when you have jest-playwright? I.e. if I just the fish shell with auto-completion I will loose that).

If one look at what a user want to achieve with jestPlaywright.debug() it would probably be something akin to:

  1. Set jest.Timeout() to its maximum value, to not jest time out the test cases.
  2. Set the browserType.launch([options])``with the option devtools` to true, at least when using Chromium. (I would guess a user would want this).
  3. Pause in a certain test case, similar to await page.waitFor(1000);

I assume one option is to remove it and instead add this a recommendation on how to debug in the README.md? Not ideal maybe, not super-UX friendly but at least that should work.

@mmarkelov
Copy link
Member

I suppose we can close it. jest-playwright is using jest-circus underhood right now. And jestPlaywright.debug() also should work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants