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

jest-circus test failures #3770

Merged
merged 2 commits into from
Jun 9, 2017

Conversation

aaronabramov
Copy link
Contributor

addresses all failing tests in integration_tests/__tests__/failures-test.js

  • handles native node assert module failures
  • expect.assertions(555)
  • minor formatting tweaks to make errors to be formatted the same way we do it with jasmine

expect.getState = () => global[GLOBAL_STATE].state;
expect.getState = getState;
expect.setState = setState;
expect.extractExpectedAssertionsErrors = extractExpectedAssertionsErrors;
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 brought in here. It used to be inside jasmine package, which i think is wrong place for it to be in, since it deals with many matcher implementation details (accessing state, formatting errors, etc.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@thymikee yeah! i agree for assert support, but expect.assertions is another story, since it's an expect feature and heavily coupled to matchers package

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, I looked at wrong code 😅
👍

@@ -0,0 +1,48 @@
/**
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 extracted this from jest-matchers/src/index.js

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we can call it jestMatchersObject? (btw would be nice to settle on naming convention for files)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@thymikee that's a good name! i'll use that.

and yeah, our file naming conventions are broken :(

Copy link
Collaborator

Choose a reason for hiding this comment

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

Renaming them would be quite easy since we have Flow though

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renaming is not hard. agreeing on the convention is :D

i only like undercores + everything lower case (dependency_resolver.js) because:

  • macOS is case insensitive, and case issues happen quite often ("works locally, breaks on CI", or "i renamed the file, but it's already added to git and git won't see my new name")
  • no one knows when to capitalize filenames (is it when exporting classes? or objects? or functions?) and it's always a mess

using camel case tho saves 1 character everywhere you'd type an underscore, and it looks more like what you'd name a variable in JS.

it's definitely unrelated to the PR though :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Put the comment in relevant issue ;)

* @flow
*/

import type {DiffOptions} from 'jest-diff/src/diffStrings';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you run prettier on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call :)

break;
}
}
};

const _addExpectedAssertionErrors = (test: TestEntry) => {
const errors = extractExpectedAssertionsErrors();
errors.length && (test.status = 'fail');
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know it is shorter, but I think it would be more readble like this, no?

if (errors.length) {
  test.status = 'fail'
}

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 would disagree with readability, recently i find it very hard to navigate through 100 lines functions that do just 2 things, but i agree that this line messes up semantics pretty bad by using a logical operator as an if condition :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, as long as we don't have pattern matching :D

getMatchers,
getState,
setMatchers,
setState,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since these are functions, not belonging to a class, wouldn't it be better to use this naming?

  • getMatchersState
  • setMatchersState

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's still namespaced within the matchers package though.
and with this naming the other two functions will become getMatchersMatchers then :D

Copy link
Collaborator

@thymikee thymikee left a comment

Choose a reason for hiding this comment

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

Looking good. Left some comments inlined.

@@ -17,6 +17,25 @@ const normalizeDots = text => text.replace(/\.{1,}$/gm, '.');

skipOnWindows.suite();

const cleanupStackTrace = stderr => {
Copy link
Member

Choose a reason for hiding this comment

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

Can we make sure this function verifies that there is a stack trace for both and fails if one of them or both are missing? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can't run both versions yet (jasmine and circus). And this is mostly for me. when i'm done with circus this will be removed, and the error is there only to make sure i don't forget to remove it after i'm done :)

@@ -220,7 +220,7 @@ const _formatError = (error: ?Exception): string => {
} else if (error.message) {
return error.message;
} else {
return String(error);
return `${String(error)} thrown`;
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 are turning it into a sentence, it needs to end with a ..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the way jasmine throws errors now, i just change it to this to be compatible with current snapshots

@aaronabramov aaronabramov force-pushed the failure-messages-1 branch 2 times, most recently from 8a57c1c to 1dbfa55 Compare June 9, 2017 17:31
@codecov-io
Copy link

Codecov Report

Merging #3770 into master will decrease coverage by 0.43%.
The diff coverage is 22.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3770      +/-   ##
==========================================
- Coverage   58.09%   57.65%   -0.44%     
==========================================
  Files         191      194       +3     
  Lines        6708     6773      +65     
  Branches        6        6              
==========================================
+ Hits         3897     3905       +8     
- Misses       2808     2865      +57     
  Partials        3        3
Impacted Files Coverage Δ
packages/jest-circus/src/formatNodeAssertErrors.js 0% <0%> (ø)
packages/jest-circus/src/utils.js 0% <0%> (ø) ⬆️
packages/jest-circus/src/state.js 0% <0%> (ø) ⬆️
.../src/legacy_code_todo_rewrite/jest-adapter-init.js 0% <0%> (ø) ⬆️
...st-matchers/src/extractExpectedAssertionsErrors.js 13.33% <13.33%> (ø)
packages/jest-matchers/src/jest-matchers-object.js 80% <80%> (ø)
packages/jest-matchers/src/index.js 97.46% <88.88%> (+2.28%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dec54a3...bab4eac. Read the comment docs.

@aaronabramov aaronabramov merged commit 328dcdd into jestjs:master Jun 9, 2017
@aaronabramov aaronabramov deleted the failure-messages-1 branch June 9, 2017 18:39
tushardhole pushed a commit to tushardhole/jest that referenced this pull request Aug 21, 2017
* jest-cirtus failure tests

* jest-circus failure messages
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants