Skip to content

Commit 5044be2

Browse files
authored
chore: upgrade Jest to 26 (#1151)
* chore: upgrade Jest to 26 * jest@26.3.0 * bump pretty-format too * bump types to 26 as well * chore: use latest; update snapshot * chore: bump pretty-format as well * yarn deduplicate
1 parent e60eeb9 commit 5044be2

File tree

8 files changed

+889
-627
lines changed

8 files changed

+889
-627
lines changed

jest.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const common = {
22
testEnvironment: 'node',
33
snapshotSerializers: [require.resolve('jest-snapshot-serializer-raw')],
4+
testRunner: 'jest-circus/runner',
45
};
56

67
module.exports = {

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
"@babel/preset-typescript": "^7.3.3",
3131
"@react-native-community/eslint-config": "^2.0.0",
3232
"@types/glob": "^7.1.1",
33-
"@types/jest": "^25.1.4",
33+
"@types/jest": "^26.0.15",
3434
"@types/mkdirp": "^0.5.2",
3535
"@types/node": "^10.0.0",
3636
"@types/node-fetch": "^2.3.7",
37-
"babel-jest": "^25.2.4",
37+
"babel-jest": "^26.6.2",
3838
"babel-plugin-module-resolver": "^3.2.0",
3939
"chalk": "^3.0.0",
4040
"chokidar": "^3.3.1",
@@ -45,7 +45,8 @@
4545
"eslint-plugin-import": "^2.17.0",
4646
"execa": "^1.0.0",
4747
"glob": "^7.1.3",
48-
"jest": "^25.2.4",
48+
"jest": "^26.6.2",
49+
"jest-circus": "^26.6.2",
4950
"jest-snapshot-serializer-raw": "^1.1.0",
5051
"lerna": "^3.18.4",
5152
"metro-memory-fs": "^0.63.0",

packages/cli-server-api/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"compression": "^1.7.1",
1313
"connect": "^3.6.5",
1414
"errorhandler": "^1.5.0",
15-
"pretty-format": "^25.1.0",
15+
"pretty-format": "^26.6.2",
1616
"serve-static": "^1.13.1",
1717
"ws": "^1.1.0"
1818
},

packages/cli/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"mkdirp": "^0.5.1",
5858
"node-stream-zip": "^1.9.1",
5959
"ora": "^3.4.0",
60-
"pretty-format": "^25.2.0",
60+
"pretty-format": "^26.6.2",
6161
"semver": "^6.3.0",
6262
"serve-static": "^1.13.1",
6363
"strip-ansi": "^5.2.0",

packages/cli/src/tools/config/__mocks__/resolveNodeModuleDir.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const path = require('path');
1+
import path from 'path';
22

33
export default function resolveNodeModuleDir(
44
root: string,

packages/cli/src/tools/config/__tests__/__snapshots__/index-test.ts.snap

+4
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,7 @@ Object {
118118
},
119119
}
120120
`;
121+
122+
exports[`should skip packages that have invalid configuration: dependencies config 1`] = `Object {}`;
123+
124+
exports[`should skip packages that have invalid configuration: logged warning 1`] = `"Package react-native has been ignored because it contains invalid configuration. Reason: \\"dependency.invalidProperty\\" is not allowed"`;

packages/cli/src/tools/config/__tests__/index-test.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010

1111
jest.mock('../resolveNodeModuleDir');
1212

13-
const DIR = getTempDirectory('resolve_config_path_test');
13+
let DIR = getTempDirectory('config_test');
1414

1515
const iosPath = slash(
1616
require.resolve('@react-native-community/cli-platform-ios'),
@@ -60,6 +60,7 @@ beforeEach(async () => {
6060
afterEach(async () => await cleanup(DIR));
6161

6262
test('should have a valid structure by default', () => {
63+
DIR = getTempDirectory('config_test_structure');
6364
writeFiles(DIR, {
6465
'react-native.config.js': `module.exports = {
6566
reactNativePath: "."
@@ -70,6 +71,7 @@ test('should have a valid structure by default', () => {
7071
});
7172

7273
test('should return dependencies from package.json', () => {
74+
DIR = getTempDirectory('config_test_deps');
7375
writeFiles(DIR, {
7476
...REACT_NATIVE_MOCK,
7577
'node_modules/react-native-test/package.json': '{}',
@@ -87,6 +89,7 @@ test('should return dependencies from package.json', () => {
8789
});
8890

8991
test('should read a config of a dependency and use it to load other settings', () => {
92+
DIR = getTempDirectory('config_test_settings');
9093
writeFiles(DIR, {
9194
...REACT_NATIVE_MOCK,
9295
'node_modules/react-native-test/package.json': '{}',
@@ -114,6 +117,7 @@ test('should read a config of a dependency and use it to load other settings', (
114117
});
115118

116119
test('should merge project configuration with default values', () => {
120+
DIR = getTempDirectory('config_test_merge');
117121
writeFiles(DIR, {
118122
...REACT_NATIVE_MOCK,
119123
'node_modules/react-native-test/package.json': '{}',
@@ -151,6 +155,7 @@ test('should merge project configuration with default values', () => {
151155
});
152156

153157
test('should load commands from "react-native-foo" and "react-native-bar" packages', () => {
158+
DIR = getTempDirectory('config_test_packages');
154159
writeFiles(DIR, {
155160
'node_modules/react-native-foo/package.json': '{}',
156161
'node_modules/react-native-foo/react-native.config.js': `module.exports = {
@@ -181,9 +186,8 @@ test('should load commands from "react-native-foo" and "react-native-bar" packag
181186
expect(commands).toMatchSnapshot();
182187
});
183188

184-
// @todo: figure out why this test is so flaky
185-
// eslint-disable-next-line jest/no-disabled-tests
186-
test.skip('should skip packages that have invalid configuration', () => {
189+
test('should skip packages that have invalid configuration', () => {
190+
DIR = getTempDirectory('config_test_skip');
187191
writeFiles(DIR, {
188192
'node_modules/react-native/package.json': '{}',
189193
'node_modules/react-native/react-native.config.js': `module.exports = {
@@ -204,6 +208,7 @@ test.skip('should skip packages that have invalid configuration', () => {
204208
});
205209

206210
test('does not use restricted "react-native" key to resolve config from package.json', () => {
211+
DIR = getTempDirectory('config_test_restricted');
207212
writeFiles(DIR, {
208213
'node_modules/react-native-netinfo/package.json': `{
209214
"react-native": "src/index.js"
@@ -221,6 +226,7 @@ test('does not use restricted "react-native" key to resolve config from package.
221226
});
222227

223228
test('supports dependencies from user configuration with custom root and properties', () => {
229+
DIR = getTempDirectory('config_test_custom_root');
224230
const escapePathSeparator = (value: string) =>
225231
path.sep === '\\' ? value.replace(/(\/|\\)/g, '\\\\') : value;
226232

0 commit comments

Comments
 (0)