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

chore: make tests compatible with Jest 24 #15779

Merged
merged 5 commits into from
Aug 14, 2019

Conversation

SimenB
Copy link
Contributor

@SimenB SimenB commented May 30, 2019

This is #15778 without the actual upgrade to Jest 24 (as that breaks CI). I'm hopeful this will pass so it can land, then the diff for Jest 24 is just config changes.

Note that this does upgrade jest to the latest 23 release, which is why the lockfile has so many changes

@SimenB SimenB force-pushed the jest-24-without-version-bump branch from cda46a0 to 96fdb14 Compare May 30, 2019 12:53
@sizebot
Copy link

sizebot commented May 30, 2019

No significant bundle size changes to report.

Generated by 🚫 dangerJS

@SimenB SimenB force-pushed the jest-24-without-version-bump branch from 96fdb14 to 601f157 Compare May 30, 2019 13:01
@@ -9,10 +9,6 @@ global.__PROFILE__ = NODE_ENV === 'development';
global.__UMD__ = false;

if (typeof window !== 'undefined') {
global.requestAnimationFrame = function(callback) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

jsdom comes with raf

// - calling 'window.postMessage' should actually fire postmessage handlers
global.requestAnimationFrame = function(cb) {
return setTimeout(() => {
cb(Date.now());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the raf from jsdom passes in the timestamp. is this safe to remove?

@SimenB SimenB force-pushed the jest-24-without-version-bump branch from 02f4bec to 7d6f4a3 Compare June 11, 2019 10:57
@SimenB SimenB force-pushed the jest-24-without-version-bump branch from 7d6f4a3 to ae0dfe7 Compare August 7, 2019 11:31
@SimenB
Copy link
Contributor Author

SimenB commented Aug 7, 2019

@threepointone I've rebased this PR. I'd love to see it land, then landing the upgrade to Jest 24 should be simpler as the diff will be cleaner

@@ -21,4 +21,5 @@ module.exports = {
collectCoverageFrom: ['packages/**/*.js'],
timers: 'fake',
snapshotSerializers: [require.resolve('jest-snapshot-serializer-raw')],
testURL: 'about:blank',
Copy link
Contributor Author

@SimenB SimenB Aug 7, 2019

Choose a reason for hiding this comment

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

Note that doing this breaks in JSDOM@>=11.12 with SecurityError: localStorage is not available for opaque origins which is why the default has changed in Jest. Can try to do something for this when Jest 25 is released, which will force a newer version of JSDOM.

For now, I've manually made sure the entry in the lockfile is ~11.11.0, which does not have this issue

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a short TODO here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ergh, expect it wasn't particularly short 😅

Copy link
Contributor

@threepointone threepointone left a comment

Choose a reason for hiding this comment

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

This LGTM! I’ll merge it later today after I try it locally just to be doubly sure.

@@ -21,4 +21,5 @@ module.exports = {
collectCoverageFrom: ['packages/**/*.js'],
timers: 'fake',
snapshotSerializers: [require.resolve('jest-snapshot-serializer-raw')],
testURL: 'about:blank',
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a short TODO here?

package.json Outdated Show resolved Hide resolved
@@ -70,7 +70,7 @@ module.exports = {
}
: {}
)
).code;
Copy link
Contributor Author

@SimenB SimenB Aug 7, 2019

Choose a reason for hiding this comment

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

removing this ensures you return source maps to Jest, for better errors and debugging.

@SimenB SimenB force-pushed the jest-24-without-version-bump branch 2 times, most recently from 81db1dd to 081bd2e Compare August 9, 2019 10:37
@SimenB
Copy link
Contributor Author

SimenB commented Aug 9, 2019

@threepointone congrats on the 16.9 release 😀 I've rebased this after #16297 was merged

@@ -651,7 +651,7 @@ describe('ReactDOMServerIntegration', () => {
});
});

describe('component hierarchies', async function() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

describe must be void (in reality it must be synchronous) in Jest. async here was always an error, but it throws with jest 24.

https://jestjs.io/docs/en/troubleshooting#defining-tests

@@ -543,3 +543,4 @@ describe 'ReactCoffeeScriptClass', ->
node = ReactDOM.findDOMNode(instance)
expect(node).toBe container.firstChild
undefined
undefined
Copy link
Contributor Author

Choose a reason for hiding this comment

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

same as the async describe - the return value must be void.

@SimenB
Copy link
Contributor Author

SimenB commented Aug 9, 2019

Since I was messing with the jest setup, I also sent #16332 which seems to have uncovered some erroneously passing tests

@SimenB SimenB force-pushed the jest-24-without-version-bump branch from 25865db to 74c40df Compare August 13, 2019 23:59
@threepointone
Copy link
Contributor

I merged the other one before this one, and this now has a conflict with yarn.lock. Sorry! 😅If you could rebase and make sure the lockfile is fine, I'll merge this in. Thank you!

@SimenB SimenB force-pushed the jest-24-without-version-bump branch from 74c40df to b7ce9a9 Compare August 14, 2019 11:01
@SimenB
Copy link
Contributor Author

SimenB commented Aug 14, 2019

Rebased! 🙂

@threepointone threepointone merged commit e308a03 into facebook:master Aug 14, 2019
@SimenB SimenB deleted the jest-24-without-version-bump branch August 14, 2019 11:48
@SimenB
Copy link
Contributor Author

SimenB commented Aug 14, 2019

🎉

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

Successfully merging this pull request may close these issues.

4 participants