-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Use jest #7455
Conversation
test/testSetupFile.js
Outdated
@@ -0,0 +1,2 @@ | |||
/* eslint-env jasmine */ | |||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use jest.setTimeout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -32,11 +43,4 @@ if (process.env.BABEL_ENV === "cov") { | |||
config.plugins.push("babel-plugin-istanbul"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this still be here? Jest adds it itself (and you removed it from package.json)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch
.babelrc.js
Outdated
@@ -40,7 +40,6 @@ const config = { | |||
|
|||
if (process.env.BABEL_ENV === "cov") { | |||
config.auxiliaryCommentBefore = "istanbul ignore next"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jest also does this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:) even better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is no need to use the mocha runner, because just using the default jest runner works fine. |
.travis.yml
Outdated
- '8' | ||
- '6' | ||
- '4' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems unrelated? We are we dropping node 4 testing already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use node
environment and keep 4? (like in babel-upgrade)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's because of jest, it still works on node 4 if you use the node environment - https://github.com/babel/babel-upgrade works fine with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok cool, I revert then.
@@ -180,15 +180,17 @@ export default function( | |||
if (!deprecationWarningShown) { | |||
deprecationWarningShown = true; | |||
|
|||
const deprecationError = new Error( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with just not doing the warning anymore and making this a breaking change. We can just fix this automatically with https://github.com/babel/babel-upgrade
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do this in a separate PR.
I agree with @danez! The Mocha runner is a good option when the complexity of the codebase makes it hard to fully migrate to Jest or as an intermediate step. Seem that I'll close it in favor of this, I can reopen it if needed. |
Ok well if this works I'm for it too 👍 , thanks for your efforts @rogeliog, sorry we didn't actually end up merging the PR 😅 |
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/7039/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's get this landed!
Ok I hope the coverage is now correct. Okay I reverted this change and instead we test the transpiled code in |
Anything jest can do to help/improve, or is it just a quirk (feature) of babel's tests? |
I think that we in the past implemented some features that jest might already do, like running each test in a spearate vm (https://github.com/babel/babel/blob/master/packages/babel-helper-transform-fixture-test-runner/src/index.js#L87). |
Super cool 👍I was wondering - it should be possible to migrate to builtin snapshots instead of custom setup in the future, right? This would allow easier test updates |
I actually like the individual files lol compared to reading the snapshot output now lol |
What's the difference though? A single snapshot format? Maybe it's possible to integrate with snapshot system to output whatever we want in whatever directory we want, just have it backed by jest's built-in system for this. |
Oh ok if you can change the format then that's cool. I just mean https://github.com/babel/babel-upgrade/blob/51534a4bd3f742d284d42e231ae36e71c83bc93d/__tests__/__snapshots__/packageData.test.js.snap#L5-L12 vs the actual js |
Actually I have no idea if its possible to change the whole format, it's for sure possible to write custom serializer, but not sure if a snapshot file can be an actual js file, not assigned to exports etc (jest snapshots are actually requireable). Worth investigating in the future |
Rebase of #6179. Seems i removed my fork repo. :)
All tests work, babel-register is skipped for now. But I have an idea how to fix it, by mocking pirates and just checking what babel-register is doing, pirates is covered with tests anyway so we don't have to test it.