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

jestPuppeteer.debug support in Jest-circus #255

Closed
brbrr opened this issue Jul 5, 2019 · 5 comments
Closed

jestPuppeteer.debug support in Jest-circus #255

brbrr opened this issue Jul 5, 2019 · 5 comments

Comments

@brbrr
Copy link

brbrr commented Jul 5, 2019

💬 Questions and Help

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

I have this CustomEnvironemnt class that should stop the execution on test failure:

const PuppeteerEnvironment = require( 'jest-environment-puppeteer' );

class CustomEnvironemnt extends PuppeteerEnvironment {
	async handleTestEvent( event ) {
		if ( event.name === 'test_fn_failure' ) {
			await this.global.jestPuppeteer.debug();
		}
	}
}

It does trigger the chrome's debugger, but unfortunately, after resuming the debugger - browser just closes itself.

@gregberge
Copy link
Member

Hello @brbrr, yeah jestPuppeteer.debug() is kind of hacky and we should remove it. The only problem here is that we don't have any correct way to set the timeout of the fly to actually "pause" a test in Jest.

@brbrr
Copy link
Author

brbrr commented Jul 9, 2019

make sense. What would you recommend as an alternative? I wonder if we can use some sort of DEBUG env variable to setup jest timeouts, and run the debugger on test failure or on-demand (similar to jestPuppeteer.debug())

@gregberge
Copy link
Member

Hello yes maybe it would be a good solution but no very user-friendly.

@sergtimosh
Copy link

sergtimosh commented Feb 8, 2020

Have you tried adding freaky timeout as test argument?(I'm not using custom environment, just add jestPuppeteer.debug() to each test while test development)
It is the only way I can use debug
Just like this:

jest.retryTimes(3)

describe('Test', () => {
    test('Test_1', async () => {
        await loginPage.login()
        await jestPuppeteer.debug() //paused in browser, and after resuming in browser stays paused in test runner
        await loginPageAssert.isLoggedIn()
    }, 999999) //timeout

})

@MatthiasEngh
Copy link
Contributor

MatthiasEngh commented Oct 21, 2020

This question is asked all over the place. The timeout https://github.com/smooth-code/jest-puppeteer/blob/master/packages/jest-environment-puppeteer/src/PuppeteerEnvironment.js#L42 is maybe ignored due to the same reason as jestjs/jest#9359. You can use --testtimeoutnumber to test: https://jestjs.io/docs/en/cli#--testtimeoutnumber

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants