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

Stalls when processing test bodies #257

Closed
mjdease opened this issue Oct 19, 2018 · 2 comments
Closed

Stalls when processing test bodies #257

mjdease opened this issue Oct 19, 2018 · 2 comments
Labels

Comments

@mjdease
Copy link

mjdease commented Oct 19, 2018

Describe the bug
Test runs appear to stall at the end when using this reporter.
I'm upgrading from v3.0.2 to 3.1.0, it appears this new regex used in cleanCode chokes on certain strings:

.replace(/^(?:.|\s)*?(?:{|=>) *\n?(?:\(|{)?/, '') // replace function declaration

Code Reproduce
I pulled out the regex from cleanCode and used a sample string to demonstrate the issue. Run the following lines in a node session and notice the str.replace call does not complete.

> let str =  "\"Failure type was error - return eventSpies.validationError.dispatch.lastCall.args[0].errorResponse.type === 'error';\"\
\"Failure code was service error - return eventSpies.validationError.dispatch.lastCall.args[0].errorResponse.code === 4;\
\"Blackout validator failed - return eventSpies.validationError.dispatch.lastCall.args[0].errorResponse.validatorType === 'top.validator.blackout';\"\
\"Validation failed once - return eventSpies.validationError.dispatch.calledOnce;\"\
\"Content failed from error  - return eventSpies.contentError.dispatch.calledOnce;\"\
\"Content state is error - return player.model().contentState() === TOP.player.ContentState.Error;\""

> str = str.replace(/\r\n|[\r\n\u2028\u2029]/g, '\n').replace(/^\uFEFF/, '').replace(/^(?:.|\s)*?(?:{|=>) *\n?(?:\(|{)?/, '')

Expected behavior
String processing should complete.

Environment (please complete the following information):

  • Platform macOS 10.14
  • mochawesome version 3.1.0
  • mocha (or other test library) 5.2.0
  • Node version 10.12.0 (also observed on 9.5.0)

Additional context
Our test implementation overrides the test bodies with formatted versions of our assertions which is why the sample string used in the example doesn't look like a valid function.

@adamgruber
Copy link
Owner

Fixed in 3.1.1

@mjdease
Copy link
Author

mjdease commented Oct 22, 2018

Thanks for the quick fix!

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

No branches or pull requests

2 participants