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 = { module.exports = {
babelrcRoots: ['examples/*'], babelrcRoots: ['examples/*'],
overrides: [ overrides: [
{
presets: ['@babel/preset-flow'],
test: '**/*.js',
},
{ {
plugins: [ plugins: [
'babel-plugin-typescript-strip-namespaces', 'babel-plugin-typescript-strip-namespaces',

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,5 +11,8 @@
"setupFiles": [ "setupFiles": [
"<rootDir>/setup.js" "<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. // 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": { "jest": {
"testEnvironment": "node" "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. // 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": { "jest": {
"testEnvironment": "node" "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/", "/node_modules/",
"/packages/" "/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/", "/node_modules/",
"/packages/" "/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-modules-commonjs": "^7.1.0",
"@babel/plugin-transform-strict-mode": "^7.0.0", "@babel/plugin-transform-strict-mode": "^7.0.0",
"@babel/preset-env": "^7.1.0", "@babel/preset-env": "^7.1.0",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0", "@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.0.0", "@babel/preset-typescript": "^7.0.0",
"@babel/register": "^7.0.0", "@babel/register": "^7.0.0",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -793,14 +793,6 @@
js-levenshtein "^1.1.3" js-levenshtein "^1.1.3"
semver "^5.3.0" 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": "@babel/preset-react@*", "@babel/preset-react@^7.0.0":
version "7.0.0" version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.0.0.tgz#e86b4b3d99433c7b3e9e91747e2653958bc6b3c0" resolved "https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.0.0.tgz#e86b4b3d99433c7b3e9e91747e2653958bc6b3c0"