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

Fix usage of this.skip() within tests #17245

Closed
rsimha opened this issue Aug 1, 2018 · 2 comments · Fixed by #17265
Closed

Fix usage of this.skip() within tests #17245

rsimha opened this issue Aug 1, 2018 · 2 comments · Fixed by #17265

Comments

@rsimha
Copy link
Contributor

rsimha commented Aug 1, 2018

Using this.skip() within tests can cause afterEach() to be skipped. mochajs/mocha#2148

In addition, this.skip() doesn't work from within a nested describe block. mochajs/mocha#2683

Figure out how to get past these two issues while still allowing tests to dynamically skip themselves.

@rsimha
Copy link
Contributor Author

rsimha commented Aug 1, 2018

/cc @jridgewell @choumx @cramforce @lannka @aghassemi @alanorozco

From the debugging I did, this.skip() is causing dirty global state in a handful of test suites, which could explain a chunk of the seemingly arbitrary failures we've been seeing.

Sadly, I don't think there's a good workaround at the mocha level to get past this. We're going to have to come up with a way to not call this.skip() if a test must be skipped, but instead make the test return without doing anything.

@rsimha
Copy link
Contributor Author

rsimha commented Aug 2, 2018

According to https://mochajs.org/#inclusive-tests, use of this.skip() is okay in before(), since none of the beforeEach() setup is done at that point. The problem only occurs when this.skip() is called in beforeEach(), because by then, the global beforeEach() will have been run, but the global afterEach() will be bypassed.

I think we can work with this limitation.

In addition, there's a workaround for using this.skip() in a nested describe block that we should put in place: mochajs/mocha#2683 (comment)

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

Successfully merging a pull request may close this issue.

1 participant