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(jest task): Return error when tests fail #1053

Merged
merged 2 commits into from
Feb 21, 2019

Conversation

michaelw85
Copy link
Contributor

Callback always resolved successfully even when test failed
Incorrect data was accessed in result data to determine failure

Closes #1052

@michaelw85
Copy link
Contributor Author

Result after change in azure devops pipeline forcefully making a test fail:

image

lib/resources/tasks/jest.js Outdated Show resolved Hide resolved
Callback always resolved successfully even when test failed
Incorrect data was accessed in result data to determine failure

Closes aurelia#1052
@michaelw85 michaelw85 force-pushed the 1052_fix_jest_no_error branch from b42c7ce to bfbe072 Compare February 18, 2019 21:17
cb(new PluginError('gulp-jest', { message: 'Tests Failed' }));
jest.runCLI(options, [path.resolve(__dirname, '../../')]).then(({ results }) => {
if (results.numFailedTests || results.numFailedTestSuites) {
cb(new PluginError('jest-cli', { message: 'Tests Failed' }));
Copy link
Member

Choose a reason for hiding this comment

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

It looks like (existing code) new PluginError generated excessive output in the console. To my limited understanding of gulp, it seems this is not a place for PluginError because it's not within context of a plugin.

Following gulpjs's example, cb(new Error('Tests Failed')); is enough and probably the correct way. @JeroenVinke can you have a look?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have hardly any experience with Gulp so left it in place, I agree the output seems excessive but it resolved the issue which was more important in my case. I will replace it with an error in my local setup and test to see if it also forces a build failure (I assume it does). If it needs to be replaced please let me know and I will update the PR.

Copy link
Member

Choose a reason for hiding this comment

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

BTW, it looks jest is only feature in cli that uses plugin-error as a dep. If we decide to get rid of PluginError here, we can cleanup the dependencies.json and unit-test-runners/jest.js too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When using new Error('...') the build fails as expected:
image

@huochunpeng I think we can replace the PluginError.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Today I also noticed just returning a string in the callback is enough to make it show an error.

Copy link
Member

Choose a reason for hiding this comment

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

Today I also noticed just returning a string in the callback is enough to make it show an error.

That's even better! Let's just clean up everything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@huochunpeng Updated and removed plugin-error package.

Remove plugin error, returning a message is enough to make the process
emit an error.
@3cp
Copy link
Member

3cp commented Feb 20, 2019

@EisenbergEffect this can be merged.

@EisenbergEffect EisenbergEffect merged commit 90f3815 into aurelia:master Feb 21, 2019
@michaelw85 michaelw85 deleted the 1052_fix_jest_no_error branch February 21, 2019 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

au jest task passes when it should fail/throw error/exit 1
3 participants