Skip to content

Commit

Permalink
Upgrade to Jest 25
Browse files Browse the repository at this point in the history
Summary:
This diff upgrades Jest to the latest version which fixes a bunch of issues with snapshots (therefore allowing me to enable the Pressable-test again). Note that this also affects Metro and various other tooling as they all depend on packages like `jest-worker`, `jest-haste-map` etc.

Breaking changes: https://github.com/facebook/jest/blob/master/CHANGELOG.md

This diff increases node_modules by 3 MiB, primarily because it causes more duplicates of `source-map` (0.8 MiB for each copy) and packages like `chalk` 3.x (vs 2.x). The base install was 15 MiB bigger and I reduced it to this size by playing around with various manual yarn.lock optimizations. However, D21085929 reduces node_modules by 11 MiB and the Babel upgrade reduced node_modules by 13 MiB. I will subsequently work on reducing the size through other packages as well and I'm working with the Jest folks to get rid of superfluous TypeScript stuff for Jest 26.

Other changes in this diff:
* Fixed Pressable-test
* Blackhole node-notifier: It's large and we don't need it, and also the license may be problematic, see: jestjs/jest#8918
* Updated jest-junit (not a Jest package) but blackholed it internally because it is only used for open source CI.
* Updated some API calls we use from Jest to account for breaking changes
* Made two absolutely egrigious changes to existing product code tests to make them still pass as our match of async/await, fake timers and then/promise using `setImmediate` is tripping up `regenerator` with `Generator is already run` errors in Jest 25. These tests should probably be rewritten.
* Locked everything to the same `resolve` version that we were already using, otherwise it was somehow pulling in 1.16 even though nothing internally uses it.

Changelog: [General] Update Jest

Reviewed By: rickhanlonii

Differential Revision: D21064825

fbshipit-source-id: d0011a51355089456718edd84ea0af21fd923a58
  • Loading branch information
cpojer authored and facebook-github-bot committed Apr 20, 2020
1 parent b651e53 commit a959188
Show file tree
Hide file tree
Showing 9 changed files with 1,332 additions and 761 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -17,7 +17,7 @@
"@babel/preset-env": "^7.0.0",
"acorn": "^5.1.2",
"babel-eslint": "^10.0.1",
"babel-preset-jest": "^24.9.0",
"babel-preset-jest": "^25.4.0",
"chalk": "^2.4.1",
"codecov": "^3.6.5",
"debug": "^2.2.0",
Expand All @@ -36,7 +36,7 @@
"glob": "^7.1.1",
"istanbul-api": "^1.1.0",
"istanbul-lib-coverage": "^1.0.0",
"jest": "^24.9.0",
"jest": "^25.4.0",
"lerna": "2.4.0",
"micromatch": "^2.3.11",
"mkdirp": "^0.5.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/metro-config/package.json
Expand Up @@ -14,13 +14,13 @@
"license": "MIT",
"dependencies": {
"cosmiconfig": "^5.0.5",
"jest-validate": "^24.9.0",
"jest-validate": "^25.4.0",
"metro": "0.59.0",
"metro-cache": "0.59.0",
"metro-core": "0.59.0"
},
"devDependencies": {
"pretty-format": "^24.9.0",
"pretty-format": "^25.4.0",
"strip-ansi": "^4.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/metro-core/package.json
Expand Up @@ -12,7 +12,7 @@
"cleanup-release": "test ! -e build && mv src build && mv src.real src"
},
"dependencies": {
"jest-haste-map": "^24.9.0",
"jest-haste-map": "^25.4.0",
"lodash.throttle": "^4.1.1",
"metro-resolver": "0.59.0"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/metro/package.json
Expand Up @@ -35,8 +35,8 @@
"graceful-fs": "^4.1.3",
"image-size": "^0.6.0",
"invariant": "^2.2.4",
"jest-haste-map": "^24.9.0",
"jest-worker": "^24.9.0",
"jest-haste-map": "^25.4.0",
"jest-worker": "^25.4.0",
"json-stable-stringify": "^1.0.1",
"lodash.throttle": "^4.1.1",
"merge-stream": "^1.0.1",
Expand All @@ -57,7 +57,7 @@
"mkdirp": "^0.5.1",
"node-fetch": "^2.2.0",
"nullthrows": "^1.1.1",
"resolve": "^1.5.0",
"resolve": "^1.15.1",
"rimraf": "^2.5.4",
"serialize-error": "^2.1.0",
"source-map": "^0.5.6",
Expand Down
4 changes: 2 additions & 2 deletions packages/metro/src/DeltaBundler/WorkerFarm.js
Expand Up @@ -67,9 +67,9 @@ class WorkerFarm {
}
}

kill(): void {
async kill(): Promise<void> {
if (this._worker && typeof this._worker.end === 'function') {
this._worker.end();
await this._worker.end();
}
}

Expand Down
Expand Up @@ -16,7 +16,7 @@ jest.mock('../DeltaCalculator');
const Bundler = require('../../Bundler');
const DeltaCalculator = require('../DeltaCalculator');

const DeltaBundler = require('../');
const DeltaBundler = require('../../DeltaBundler');

describe('DeltaBundler', () => {
let deltaBundler;
Expand Down
Expand Up @@ -99,7 +99,7 @@ describe('Worker Farm', function() {
transformerConfig,
);

farm.kill();
await farm.kill();

const anotherFarm = new WorkerFarm(
{...config, projectRoot: '/bar'},
Expand Down
2 changes: 1 addition & 1 deletion packages/metro/src/Server/__tests__/Server-test.js
Expand Up @@ -55,7 +55,7 @@ describe('processRequest', () => {
getPrependedScripts = require('../../lib/getPrependedScripts');
transformHelpers = require('../../lib/transformHelpers');
DeltaBundler = require('../../DeltaBundler');
Server = require('../');
Server = require('../../Server');
});

let server;
Expand Down

0 comments on commit a959188

Please sign in to comment.