chore: remove babel flow plugin (#8712)

This commit is contained in:
Simen Bekkhus 2019-07-19 12:39:10 +02:00 committed by GitHub
parent 33e2d5ce45
commit b9d06ad4a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 286 additions and 138 deletions

View File

@ -3,10 +3,6 @@
module.exports = {
babelrcRoots: ['examples/*'],
overrides: [
{
presets: ['@babel/preset-flow'],
test: '**/*.js',
},
{
plugins: [
'babel-plugin-typescript-strip-namespaces',

View File

@ -8,11 +8,15 @@
import fs from 'fs';
import path from 'path';
import {wrap} from 'jest-snapshot-serializer-raw';
import {extractSummary} from '../Utils';
import {extractSummary, run} from '../Utils';
import runJest from '../runJest';
const DIR = path.resolve(__dirname, '../coverage-report');
beforeAll(() => {
run('yarn', DIR);
});
test('outputs coverage report', () => {
const {stdout, status} = runJest(DIR, ['--no-cache', '--coverage'], {
stripAnsi: true,

View File

@ -8,9 +8,14 @@
import path from 'path';
import {wrap} from 'jest-snapshot-serializer-raw';
import runJest from '../runJest';
import {extractSummary} from '../Utils';
import {extractSummary, run} from '../Utils';
const dir = path.resolve(__dirname, '../expect-async-matcher');
beforeAll(() => {
run('yarn', dir);
});
test('works with passing tests', () => {
const result = runJest(dir, ['success.test.js']);
expect(result.status).toBe(0);

View File

@ -7,7 +7,7 @@
import path from 'path';
import {wrap} from 'jest-snapshot-serializer-raw';
import {extractSummary} from '../Utils';
import {extractSummary, run} from '../Utils';
import runJest from '../runJest';
const dir = path.resolve(__dirname, '../failures');
@ -21,6 +21,10 @@ function cleanStderr(stderr: string) {
.replace(new RegExp('Failed: Object {', 'g'), 'thrown: Object {');
}
beforeAll(() => {
run('yarn', dir);
});
test('not throwing Error objects', () => {
let stderr;
stderr = runJest(dir, ['throwNumber.test.js']).stderr;

View File

@ -10,7 +10,7 @@ import fs from 'fs';
import os from 'os';
import path from 'path';
import runJest, {json as runWithJson} from '../runJest';
import {cleanup} from '../Utils';
import {cleanup, run} from '../Utils';
const DIR = path.join(os.tmpdir(), 'jest-global-setup');
const project1DIR = path.join(os.tmpdir(), 'jest-global-setup-project-1');
@ -20,6 +20,11 @@ const customTransformDIR = path.join(
'jest-global-setup-custom-transform',
);
const nodeModulesDIR = path.join(os.tmpdir(), 'jest-global-setup-node-modules');
const e2eDir = path.resolve(__dirname, '../global-setup');
beforeAll(() => {
run('yarn', e2eDir);
});
beforeEach(() => {
cleanup(DIR);
@ -37,8 +42,8 @@ afterAll(() => {
});
test('globalSetup is triggered once before all test suites', () => {
const setupPath = path.resolve(__dirname, '../global-setup/setup.js');
const result = runWithJson('global-setup', [
const setupPath = path.join(e2eDir, 'setup.js');
const result = runWithJson(e2eDir, [
`--globalSetup=${setupPath}`,
`--testPathPattern=__tests__`,
]);
@ -52,7 +57,7 @@ test('globalSetup is triggered once before all test suites', () => {
test('jest throws an error when globalSetup does not export a function', () => {
const setupPath = path.resolve(__dirname, '../global-setup/invalidSetup.js');
const {status, stderr} = runJest('global-setup', [
const {status, stderr} = runJest(e2eDir, [
`--globalSetup=${setupPath}`,
`--testPathPattern=__tests__`,
]);
@ -64,14 +69,11 @@ test('jest throws an error when globalSetup does not export a function', () => {
});
test('globalSetup function gets jest config object as a parameter', () => {
const setupPath = path.resolve(
__dirname,
'../global-setup/setupWithConfig.js',
);
const setupPath = path.resolve(e2eDir, 'setupWithConfig.js');
const testPathPattern = 'pass';
const result = runJest('global-setup', [
const result = runJest(e2eDir, [
`--globalSetup=${setupPath}`,
`--testPathPattern=${testPathPattern}`,
]);
@ -80,12 +82,9 @@ test('globalSetup function gets jest config object as a parameter', () => {
});
test('should call globalSetup function of multiple projects', () => {
const configPath = path.resolve(
__dirname,
'../global-setup/projects.jest.config.js',
);
const configPath = path.resolve(e2eDir, 'projects.jest.config.js');
const result = runWithJson('global-setup', [`--config=${configPath}`]);
const result = runWithJson(e2eDir, [`--config=${configPath}`]);
expect(result.status).toBe(0);
@ -95,12 +94,9 @@ test('should call globalSetup function of multiple projects', () => {
});
test('should not call a globalSetup of a project if there are no tests to run from this project', () => {
const configPath = path.resolve(
__dirname,
'../global-setup/projects.jest.config.js',
);
const configPath = path.resolve(e2eDir, 'projects.jest.config.js');
const result = runWithJson('global-setup', [
const result = runWithJson(e2eDir, [
`--config=${configPath}`,
'--testPathPattern=project-1',
]);
@ -113,12 +109,9 @@ test('should not call a globalSetup of a project if there are no tests to run fr
});
test('should not call any globalSetup if there are no tests to run', () => {
const configPath = path.resolve(
__dirname,
'../global-setup/projects.jest.config.js',
);
const configPath = path.resolve(e2eDir, 'projects.jest.config.js');
const result = runWithJson('global-setup', [
const result = runWithJson(e2eDir, [
`--config=${configPath}`,
// onlyChanged ensures there are no tests to run
'--onlyChanged',
@ -132,14 +125,11 @@ test('should not call any globalSetup if there are no tests to run', () => {
});
test('globalSetup works with default export', () => {
const setupPath = path.resolve(
__dirname,
'../global-setup/setupWithDefaultExport.js',
);
const setupPath = path.resolve(e2eDir, 'setupWithDefaultExport.js');
const testPathPattern = 'pass';
const result = runJest('global-setup', [
const result = runJest(e2eDir, [
`--globalSetup=${setupPath}`,
`--testPathPattern=${testPathPattern}`,
]);
@ -148,12 +138,9 @@ test('globalSetup works with default export', () => {
});
test('globalSetup throws with named export', () => {
const setupPath = path.resolve(
__dirname,
'../global-setup/invalidSetupWithNamedExport.js',
);
const setupPath = path.resolve(e2eDir, 'invalidSetupWithNamedExport.js');
const {status, stderr} = runJest('global-setup', [
const {status, stderr} = runJest(e2eDir, [
`--globalSetup=${setupPath}`,
`--testPathPattern=__tests__`,
]);

View File

@ -11,11 +11,16 @@ import os from 'os';
import path from 'path';
import {createDirectory} from 'jest-util';
import runJest, {json as runWithJson} from '../runJest';
import {cleanup} from '../Utils';
import {cleanup, run} from '../Utils';
const DIR = path.join(os.tmpdir(), 'jest-global-teardown');
const project1DIR = path.join(os.tmpdir(), 'jest-global-teardown-project-1');
const project2DIR = path.join(os.tmpdir(), 'jest-global-teardown-project-2');
const e2eDir = path.resolve(__dirname, '../global-teardown');
beforeAll(() => {
run('yarn', e2eDir);
});
beforeEach(() => {
cleanup(DIR);
@ -30,10 +35,7 @@ afterAll(() => {
test('globalTeardown is triggered once after all test suites', () => {
createDirectory(DIR);
const teardownPath = path.resolve(
__dirname,
'../global-teardown/teardown.js',
);
const teardownPath = path.resolve(e2eDir, 'teardown.js');
const result = runWithJson('global-teardown', [
`--globalTeardown=${teardownPath}`,
`--testPathPattern=__tests__`,
@ -47,11 +49,8 @@ test('globalTeardown is triggered once after all test suites', () => {
});
test('jest throws an error when globalTeardown does not export a function', () => {
const teardownPath = path.resolve(
__dirname,
'../global-teardown/invalidTeardown.js',
);
const {status, stderr} = runJest('global-teardown', [
const teardownPath = path.resolve(e2eDir, 'invalidTeardown.js');
const {status, stderr} = runJest(e2eDir, [
`--globalTeardown=${teardownPath}`,
`--testPathPattern=__tests__`,
]);
@ -63,14 +62,11 @@ test('jest throws an error when globalTeardown does not export a function', () =
});
test('globalTeardown function gets jest config object as a parameter', () => {
const teardownPath = path.resolve(
__dirname,
'../global-teardown/teardownWithConfig.js',
);
const teardownPath = path.resolve(e2eDir, 'teardownWithConfig.js');
const testPathPattern = 'pass';
const result = runJest('global-teardown', [
const result = runJest(e2eDir, [
`--globalTeardown=${teardownPath}`,
`--testPathPattern=${testPathPattern}`,
]);
@ -79,10 +75,7 @@ test('globalTeardown function gets jest config object as a parameter', () => {
});
test('should call globalTeardown function of multiple projects', () => {
const configPath = path.resolve(
__dirname,
'../global-teardown/projects.jest.config.js',
);
const configPath = path.resolve(e2eDir, 'projects.jest.config.js');
const result = runWithJson('global-teardown', [`--config=${configPath}`]);
@ -94,10 +87,7 @@ test('should call globalTeardown function of multiple projects', () => {
});
test('should not call a globalTeardown of a project if there are no tests to run from this project', () => {
const configPath = path.resolve(
__dirname,
'../global-teardown/projects.jest.config.js',
);
const configPath = path.resolve(e2eDir, 'projects.jest.config.js');
const result = runWithJson('global-teardown', [
`--config=${configPath}`,
@ -112,14 +102,11 @@ test('should not call a globalTeardown of a project if there are no tests to run
});
test('globalTeardown works with default export', () => {
const teardownPath = path.resolve(
__dirname,
'../global-teardown/teardownWithDefaultExport.js',
);
const teardownPath = path.resolve(e2eDir, 'teardownWithDefaultExport.js');
const testPathPattern = 'pass';
const result = runJest('global-teardown', [
const result = runJest(e2eDir, [
`--globalTeardown=${teardownPath}`,
`--testPathPattern=${testPathPattern}`,
]);
@ -129,11 +116,11 @@ test('globalTeardown works with default export', () => {
test('globalTeardown throws with named export', () => {
const teardownPath = path.resolve(
__dirname,
'../global-teardown/invalidTeardownWithNamedExport.js',
e2eDir,
'invalidTeardownWithNamedExport.js',
);
const {status, stderr} = runJest('global-teardown', [
const {status, stderr} = runJest(e2eDir, [
`--globalTeardown=${teardownPath}`,
`--testPathPattern=__tests__`,
]);

View File

@ -11,5 +11,8 @@
"setupFiles": [
"<rootDir>/setup.js"
]
},
"devDependencies": {
"@babel/preset-flow": "^7.0.0"
}
}

View File

@ -0,0 +1,31 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@babel/helper-plugin-utils@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0.tgz#bbb3fbee98661c569034237cc03967ba99b4f250"
integrity sha512-CYAOUCARwExnEixLdB6sDm2dIJ/YgEAKDM1MOeMeZu9Ld/bDgVo8aiWrXwcY7OBh+1Ea2uUcVRcxKk0GJvW7QA==
"@babel/plugin-syntax-flow@^7.2.0":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.2.0.tgz#a765f061f803bc48f240c26f8747faf97c26bf7c"
integrity sha512-r6YMuZDWLtLlu0kqIim5o/3TNRAlWb073HwT3e2nKf9I8IIvOggPrnILYPsrrKilmn/mYEMCf/Z07w3yQJF6dg==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-transform-flow-strip-types@^7.0.0":
version "7.4.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-flow-strip-types/-/plugin-transform-flow-strip-types-7.4.4.tgz#d267a081f49a8705fc9146de0768c6b58dccd8f7"
integrity sha512-WyVedfeEIILYEaWGAUWzVNyqG4sfsNooMhXWsu/YzOvVGcsnPb5PguysjJqI3t3qiaYj0BR8T2f5njdjTGe44Q==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-syntax-flow" "^7.2.0"
"@babel/preset-flow@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/preset-flow/-/preset-flow-7.0.0.tgz#afd764835d9535ec63d8c7d4caf1c06457263da2"
integrity sha512-bJOHrYOPqJZCkPVbG1Lot2r5OSsB+iUOaxiHdlOeB1yPWS6evswVHwvkDLZ54WTaTRIk89ds0iHmGZSnxlPejQ==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-transform-flow-strip-types" "^7.0.0"

View File

@ -1,3 +1,7 @@
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
module.exports = require('../../babel.config');
const baseConfig = require('../../babel.config');
module.exports = Object.assign({}, baseConfig, {
presets: baseConfig.presets.concat('@babel/preset-flow'),
});

View File

@ -1,5 +1,8 @@
{
"jest": {
"testEnvironment": "node"
},
"devDependencies": {
"@babel/preset-flow": "^7.0.0"
}
}

View File

@ -0,0 +1,31 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@babel/helper-plugin-utils@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0.tgz#bbb3fbee98661c569034237cc03967ba99b4f250"
integrity sha512-CYAOUCARwExnEixLdB6sDm2dIJ/YgEAKDM1MOeMeZu9Ld/bDgVo8aiWrXwcY7OBh+1Ea2uUcVRcxKk0GJvW7QA==
"@babel/plugin-syntax-flow@^7.2.0":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.2.0.tgz#a765f061f803bc48f240c26f8747faf97c26bf7c"
integrity sha512-r6YMuZDWLtLlu0kqIim5o/3TNRAlWb073HwT3e2nKf9I8IIvOggPrnILYPsrrKilmn/mYEMCf/Z07w3yQJF6dg==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-transform-flow-strip-types@^7.0.0":
version "7.4.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-flow-strip-types/-/plugin-transform-flow-strip-types-7.4.4.tgz#d267a081f49a8705fc9146de0768c6b58dccd8f7"
integrity sha512-WyVedfeEIILYEaWGAUWzVNyqG4sfsNooMhXWsu/YzOvVGcsnPb5PguysjJqI3t3qiaYj0BR8T2f5njdjTGe44Q==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-syntax-flow" "^7.2.0"
"@babel/preset-flow@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/preset-flow/-/preset-flow-7.0.0.tgz#afd764835d9535ec63d8c7d4caf1c06457263da2"
integrity sha512-bJOHrYOPqJZCkPVbG1Lot2r5OSsB+iUOaxiHdlOeB1yPWS6evswVHwvkDLZ54WTaTRIk89ds0iHmGZSnxlPejQ==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-transform-flow-strip-types" "^7.0.0"

View File

@ -1,3 +1,7 @@
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
module.exports = require('../../babel.config');
const baseConfig = require('../../babel.config');
module.exports = Object.assign({}, baseConfig, {
presets: baseConfig.presets.concat('@babel/preset-flow'),
});

View File

@ -1,5 +1,8 @@
{
"jest": {
"testEnvironment": "node"
},
"devDependencies": {
"@babel/preset-flow": "^7.0.0"
}
}

31
e2e/failures/yarn.lock Normal file
View File

@ -0,0 +1,31 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@babel/helper-plugin-utils@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0.tgz#bbb3fbee98661c569034237cc03967ba99b4f250"
integrity sha512-CYAOUCARwExnEixLdB6sDm2dIJ/YgEAKDM1MOeMeZu9Ld/bDgVo8aiWrXwcY7OBh+1Ea2uUcVRcxKk0GJvW7QA==
"@babel/plugin-syntax-flow@^7.2.0":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.2.0.tgz#a765f061f803bc48f240c26f8747faf97c26bf7c"
integrity sha512-r6YMuZDWLtLlu0kqIim5o/3TNRAlWb073HwT3e2nKf9I8IIvOggPrnILYPsrrKilmn/mYEMCf/Z07w3yQJF6dg==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-transform-flow-strip-types@^7.0.0":
version "7.4.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-flow-strip-types/-/plugin-transform-flow-strip-types-7.4.4.tgz#d267a081f49a8705fc9146de0768c6b58dccd8f7"
integrity sha512-WyVedfeEIILYEaWGAUWzVNyqG4sfsNooMhXWsu/YzOvVGcsnPb5PguysjJqI3t3qiaYj0BR8T2f5njdjTGe44Q==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-syntax-flow" "^7.2.0"
"@babel/preset-flow@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/preset-flow/-/preset-flow-7.0.0.tgz#afd764835d9535ec63d8c7d4caf1c06457263da2"
integrity sha512-bJOHrYOPqJZCkPVbG1Lot2r5OSsB+iUOaxiHdlOeB1yPWS6evswVHwvkDLZ54WTaTRIk89ds0iHmGZSnxlPejQ==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-transform-flow-strip-types" "^7.0.0"

View File

@ -5,5 +5,8 @@
"/node_modules/",
"/packages/"
]
},
"devDependencies": {
"@babel/preset-flow": "^7.0.0"
}
}

View File

@ -0,0 +1,31 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@babel/helper-plugin-utils@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0.tgz#bbb3fbee98661c569034237cc03967ba99b4f250"
integrity sha512-CYAOUCARwExnEixLdB6sDm2dIJ/YgEAKDM1MOeMeZu9Ld/bDgVo8aiWrXwcY7OBh+1Ea2uUcVRcxKk0GJvW7QA==
"@babel/plugin-syntax-flow@^7.2.0":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.2.0.tgz#a765f061f803bc48f240c26f8747faf97c26bf7c"
integrity sha512-r6YMuZDWLtLlu0kqIim5o/3TNRAlWb073HwT3e2nKf9I8IIvOggPrnILYPsrrKilmn/mYEMCf/Z07w3yQJF6dg==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-transform-flow-strip-types@^7.0.0":
version "7.4.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-flow-strip-types/-/plugin-transform-flow-strip-types-7.4.4.tgz#d267a081f49a8705fc9146de0768c6b58dccd8f7"
integrity sha512-WyVedfeEIILYEaWGAUWzVNyqG4sfsNooMhXWsu/YzOvVGcsnPb5PguysjJqI3t3qiaYj0BR8T2f5njdjTGe44Q==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-syntax-flow" "^7.2.0"
"@babel/preset-flow@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/preset-flow/-/preset-flow-7.0.0.tgz#afd764835d9535ec63d8c7d4caf1c06457263da2"
integrity sha512-bJOHrYOPqJZCkPVbG1Lot2r5OSsB+iUOaxiHdlOeB1yPWS6evswVHwvkDLZ54WTaTRIk89ds0iHmGZSnxlPejQ==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-transform-flow-strip-types" "^7.0.0"

View File

@ -5,5 +5,8 @@
"/node_modules/",
"/packages/"
]
},
"devDependencies": {
"@babel/preset-flow": "^7.0.0"
}
}

View File

@ -0,0 +1,31 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@babel/helper-plugin-utils@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0.tgz#bbb3fbee98661c569034237cc03967ba99b4f250"
integrity sha512-CYAOUCARwExnEixLdB6sDm2dIJ/YgEAKDM1MOeMeZu9Ld/bDgVo8aiWrXwcY7OBh+1Ea2uUcVRcxKk0GJvW7QA==
"@babel/plugin-syntax-flow@^7.2.0":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.2.0.tgz#a765f061f803bc48f240c26f8747faf97c26bf7c"
integrity sha512-r6YMuZDWLtLlu0kqIim5o/3TNRAlWb073HwT3e2nKf9I8IIvOggPrnILYPsrrKilmn/mYEMCf/Z07w3yQJF6dg==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-transform-flow-strip-types@^7.0.0":
version "7.4.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-flow-strip-types/-/plugin-transform-flow-strip-types-7.4.4.tgz#d267a081f49a8705fc9146de0768c6b58dccd8f7"
integrity sha512-WyVedfeEIILYEaWGAUWzVNyqG4sfsNooMhXWsu/YzOvVGcsnPb5PguysjJqI3t3qiaYj0BR8T2f5njdjTGe44Q==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-syntax-flow" "^7.2.0"
"@babel/preset-flow@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/preset-flow/-/preset-flow-7.0.0.tgz#afd764835d9535ec63d8c7d4caf1c06457263da2"
integrity sha512-bJOHrYOPqJZCkPVbG1Lot2r5OSsB+iUOaxiHdlOeB1yPWS6evswVHwvkDLZ54WTaTRIk89ds0iHmGZSnxlPejQ==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-transform-flow-strip-types" "^7.0.0"

View File

@ -6,7 +6,6 @@
"@babel/plugin-transform-modules-commonjs": "^7.1.0",
"@babel/plugin-transform-strict-mode": "^7.0.0",
"@babel/preset-env": "^7.1.0",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.0.0",
"@babel/register": "^7.0.0",

View File

@ -6,10 +6,9 @@
*
*/
'use strict';
import jestExpect from '../';
const jestExpect = require('../');
const {
import {
any,
anything,
arrayContaining,
@ -17,13 +16,13 @@ const {
objectContaining,
objectNotContaining,
stringContaining,
stringNotContaining,
stringMatching,
stringNotContaining,
stringNotMatching,
} = require('../asymmetricMatchers');
} from '../asymmetricMatchers';
test('Any.asymmetricMatch()', () => {
const Thing = function() {};
class Thing {}
[
any(String).asymmetricMatch('jest'),
@ -78,7 +77,7 @@ test('Any.toAsymmetricMatcher() with function name', () => {
return $someFuncWithFakeToString;
})(),
],
].forEach(([name, fn]: [string, any]) => {
].forEach(([name, fn]) => {
jestExpect(any(fn).toAsymmetricMatcher()).toBe(`Any<${name}>`);
});
});

View File

@ -5,15 +5,12 @@
* LICENSE file in the root directory of this source tree.
*/
'use strict';
const jestExpect = require('../');
import jestExpect from '../';
// Custom Error class because node versions have different stack trace strings.
class customError extends Error {
constructor(message) {
super();
this.message = message;
class CustomError extends Error {
constructor(message?: string) {
super(message);
this.name = 'Error';
this.stack =
'Error\n' +
@ -22,14 +19,17 @@ class customError extends Error {
}
}
['toThrowError', 'toThrow'].forEach(toThrow => {
// `as const` needs newer babel which explodes on node 6
const matchers: ['toThrowError', 'toThrow'] = ['toThrowError', 'toThrow'];
matchers.forEach(toThrow => {
describe(toThrow, () => {
class Err extends customError {}
class Err2 extends customError {}
class Err extends CustomError {}
class Err2 extends CustomError {}
test('to throw or not to throw', () => {
jestExpect(() => {
throw new customError('apple');
throw new CustomError('apple');
})[toThrow]();
jestExpect(() => {}).not[toThrow]();
});
@ -37,10 +37,10 @@ class customError extends Error {
describe('substring', () => {
it('passes', () => {
jestExpect(() => {
throw new customError('apple');
throw new CustomError('apple');
})[toThrow]('apple');
jestExpect(() => {
throw new customError('banana');
throw new CustomError('banana');
}).not[toThrow]('apple');
jestExpect(() => {}).not[toThrow]('apple');
});
@ -54,7 +54,7 @@ class customError extends Error {
test('threw, but message did not match (error)', () => {
expect(() => {
jestExpect(() => {
throw new customError('apple');
throw new CustomError('apple');
})[toThrow]('banana');
}).toThrowErrorMatchingSnapshot();
});
@ -77,7 +77,7 @@ class customError extends Error {
test('threw, but message should not match (error)', () => {
expect(() => {
jestExpect(() => {
throw new customError('Invalid array length');
throw new CustomError('Invalid array length');
}).not[toThrow]('array');
}).toThrowErrorMatchingSnapshot();
});
@ -95,10 +95,10 @@ class customError extends Error {
describe('regexp', () => {
it('passes', () => {
jestExpect(() => {
throw new customError('apple');
throw new CustomError('apple');
})[toThrow](/apple/);
jestExpect(() => {
throw new customError('banana');
throw new CustomError('banana');
}).not[toThrow](/apple/);
jestExpect(() => {}).not[toThrow](/apple/);
});
@ -112,7 +112,7 @@ class customError extends Error {
test('threw, but message did not match (error)', () => {
expect(() => {
jestExpect(() => {
throw new customError('apple');
throw new CustomError('apple');
})[toThrow](/banana/);
}).toThrowErrorMatchingSnapshot();
});
@ -129,7 +129,7 @@ class customError extends Error {
test('threw, but message should not match (error)', () => {
expect(() => {
jestExpect(() => {
throw new customError('Invalid array length');
throw new CustomError('Invalid array length');
}).not[toThrow](/ array /);
}).toThrowErrorMatchingSnapshot();
});
@ -146,8 +146,8 @@ class customError extends Error {
describe('error class', () => {
class SubErr extends Err {
constructor(...args) {
super(...args);
constructor(message?: string) {
super(message);
// In a carefully written error subclass,
// name property is equal to constructor name.
this.name = this.constructor.name;
@ -155,8 +155,8 @@ class customError extends Error {
}
class SubSubErr extends SubErr {
constructor(...args) {
super(...args);
constructor(message?: string) {
super(message);
// In a carefully written error subclass,
// name property is equal to constructor name.
this.name = this.constructor.name;
@ -169,7 +169,7 @@ class customError extends Error {
})[toThrow](Err);
jestExpect(() => {
throw new Err();
})[toThrow](customError);
})[toThrow](CustomError);
jestExpect(() => {
throw new Err();
}).not[toThrow](Err2);
@ -320,7 +320,7 @@ class customError extends Error {
describe('pass', () => {
test('isNot false', () => {
jestExpect(() => {
throw new customError('apple');
throw new CustomError('apple');
})[toThrow](expect.anything());
});
@ -346,7 +346,7 @@ class customError extends Error {
test('isNot true', () => {
expect(() =>
jestExpect(() => {
throw new customError('apple');
throw new CustomError('apple');
}).not[toThrow](expect.anything()),
).toThrowErrorMatchingSnapshot();
});
@ -357,7 +357,7 @@ class customError extends Error {
// Test serialization of asymmetric matcher which has no property:
// this.$$typeof = Symbol.for('jest.asymmetricMatcher')
const matchError = {
asymmetricMatch(received) {
asymmetricMatch(received: Error | null | undefined) {
return (
received !== null &&
received !== undefined &&
@ -366,7 +366,7 @@ class customError extends Error {
},
};
const matchNotError = {
asymmetricMatch(received) {
asymmetricMatch(received: Error | null | undefined) {
return (
received !== null &&
received !== undefined &&
@ -378,13 +378,13 @@ class customError extends Error {
describe('pass', () => {
test('isNot false', () => {
jestExpect(() => {
throw new customError('apple');
throw new CustomError('apple');
})[toThrow](matchError);
});
test('isNot true', () => {
jestExpect(() => {
throw new customError('apple');
throw new CustomError('apple');
}).not[toThrow](matchNotError);
});
});
@ -393,7 +393,7 @@ class customError extends Error {
test('isNot false', () => {
expect(() =>
jestExpect(() => {
throw new customError('apple');
throw new CustomError('apple');
})[toThrow](matchNotError),
).toThrowErrorMatchingSnapshot();
});
@ -401,7 +401,7 @@ class customError extends Error {
test('isNot true', () => {
expect(() =>
jestExpect(() => {
throw new customError('apple');
throw new CustomError('apple');
}).not[toThrow](matchError),
).toThrowErrorMatchingSnapshot();
});
@ -419,13 +419,13 @@ class customError extends Error {
describe('pass', () => {
test('isNot false', () => {
jestExpect(() => {
throw new customError('apple');
throw new CustomError('apple');
})[toThrow](matchError);
});
test('isNot true', () => {
jestExpect(() => {
throw new customError('apple');
throw new CustomError('apple');
}).not[toThrow](matchNotError);
});
});
@ -434,7 +434,7 @@ class customError extends Error {
test('isNot false', () => {
expect(() =>
jestExpect(() => {
throw new customError('apple');
throw new CustomError('apple');
})[toThrow](matchNotError),
).toThrowErrorMatchingSnapshot();
});
@ -442,7 +442,7 @@ class customError extends Error {
test('isNot true', () => {
expect(() =>
jestExpect(() => {
throw new customError('apple');
throw new CustomError('apple');
}).not[toThrow](matchError),
).toThrowErrorMatchingSnapshot();
});

View File

@ -94,7 +94,7 @@ exports[`pretty prints valid config for Function 1`] = `
<red></>
<red> Example:</>
<red> {</>
<red> <bold>\\"fn\\"</>: <bold>(config, option, deprecatedOptions) => true</></>
<red> <bold>\\"fn\\"</>: <bold>(_config, _option, _deprecatedOptions) => true</></>
<red> }</>
<red></>"
`;

View File

@ -3,13 +3,12 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
const os = require('os');
const path = require('path');
const chalk = require('chalk');
import os from 'os';
import path from 'path';
import chalk from 'chalk';
const NODE_MODULES = path.sep + 'node_modules' + path.sep;
const replacePathSepForRegex = (string: string) => {
if (path.sep === '\\') {
@ -134,7 +133,7 @@ const validConfig = {
const format = (value: string) => require('pretty-format')(value, {min: true});
const deprecatedConfig = {
preprocessorIgnorePatterns: (config: Object) =>
preprocessorIgnorePatterns: (config: Record<string, any>) =>
` Option ${chalk.bold(
'preprocessorIgnorePatterns',
)} was replaced by ${chalk.bold(
@ -150,7 +149,7 @@ const deprecatedConfig = {
Please update your configuration.`,
scriptPreprocessor: (config: Object) =>
scriptPreprocessor: (config: Record<string, any>) =>
` Option ${chalk.bold('scriptPreprocessor')} was replaced by ${chalk.bold(
'transform',
)}, which support multiple preprocessors.

View File

@ -6,8 +6,6 @@
*
*/
'use strict';
import validate from '../validate';
import {multipleValidOptions} from '../condition';
import jestValidateExampleConfig from '../exampleConfig';
@ -56,7 +54,7 @@ test.each([
test(`pretty prints valid config for Function`, () => {
const config = {fn: 'test'};
const validConfig = {fn: (config, option, deprecatedOptions) => true};
const validConfig = {fn: (_config, _option, _deprecatedOptions) => true};
expect(() =>
validate(config, {
exampleConfig: validConfig,
@ -294,7 +292,7 @@ test('Comments in config JSON using "//" key are not warned', () => {
validate(config, {
exampleConfig: validConfig,
recursiveBlacklist: [('myCustomKey': "don't validate this")],
recursiveBlacklist: ['myCustomKey' as "don't validate this"],
});
expect(console.warn).not.toBeCalled();

View File

@ -793,14 +793,6 @@
js-levenshtein "^1.1.3"
semver "^5.3.0"
"@babel/preset-flow@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/preset-flow/-/preset-flow-7.0.0.tgz#afd764835d9535ec63d8c7d4caf1c06457263da2"
integrity sha512-bJOHrYOPqJZCkPVbG1Lot2r5OSsB+iUOaxiHdlOeB1yPWS6evswVHwvkDLZ54WTaTRIk89ds0iHmGZSnxlPejQ==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-transform-flow-strip-types" "^7.0.0"
"@babel/preset-react@*", "@babel/preset-react@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.0.0.tgz#e86b4b3d99433c7b3e9e91747e2653958bc6b3c0"