Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

fix(Jest): Fix Jest middleware always exit with zero code #636

Merged
merged 1 commit into from
Dec 21, 2017

Conversation

okonet
Copy link
Contributor

@okonet okonet commented Dec 19, 2017

Closes #632

Since this regression was introduced in v7, I think it should be released as a patch release in v7 and v8 accordingly.

After spending ~30 mins trying to write tests with Ava I gave up and offering my help with #635

@eliperelman
Copy link
Member

Strange, the test for this failed in travis, even though jest says the test passed.

@okonet
Copy link
Contributor Author

okonet commented Dec 19, 2017

Very strange, indeed. I've looked at Jest's results Object and it's says it's all good. Not sure where the 1 code is coming from. For some reason I also see the error code printed twice:


0
  ✔ cli_test › @neutrinojs/react (10.1s)
1
0
  ✖ cli_test › @neutrinojs/react + @neutrinojs/jest Failed to test project:

when adding a console.log here https://github.com/mozilla-neutrino/neutrino-dev/blob/master/packages/create-project/test/cli_test.js#L28

@okonet
Copy link
Contributor Author

okonet commented Dec 19, 2017

My assumption is that it was passing before since the Jest would never reject. And since the code for failing test is 18 days old, it was never technically correct with the bug in the jest preset. @eliperelman would you mind taking a look at it?

(result.numFailedTests || result.numFailedTestSuites ?
reject() :
resolve()));
jest.runCLI(cliOptions, options.roots || [options.rootDir])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just thinking, since we are no longer using a callback here, we can remove the return new Promise on L99 and instead just return the runCLI call, right?

return jest.runCLI(cliOptions, options.roots || [options.rootDir]);

Do we even then need to capture results.success, or will jest reject if success is false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't reject as far as I can say by looking at their code. I think their promise is for some unexpected inside a try ... catch. That's why they have the success property.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so we will need to manually throw or reject or whatever. Gotcha.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. The implementation I've submitted in this PR works in my repository. I dunno why are tests failing, though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'll see if I can clone locally and replicate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you make this change, I will get it out in a patch release today. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 why did it work for me? Did they break the API again or I’m just stupid? I’ll test the code again with different Jest versions to check that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, the just tests pass, the only thing was we were using the results properties from jest to determine pass or fail incorrectly, hence why it was failing our tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I mean I tried this fix on my project and it fixed the issue. That's why I submitted the fix in the first place.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm not sure. You did fix the fact that it should be a promise now, so maybe that was part of it.

@eliperelman eliperelman merged commit 1426be5 into neutrinojs:master Dec 21, 2017
@okonet
Copy link
Contributor Author

okonet commented Dec 23, 2017

You decided to go with it? I’m sorry I still didn’t have time to investigate it

timkelty pushed a commit to timkelty/neutrino that referenced this pull request Jan 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

2 participants