Skip to content

Commit

Permalink
chore: remove babel flow plugin (#8712)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Jul 19, 2019
1 parent 33e2d5c commit b9d06ad
Show file tree
Hide file tree
Showing 26 changed files with 286 additions and 138 deletions.
4 changes: 0 additions & 4 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
module.exports = {
babelrcRoots: ['examples/*'],
overrides: [
{
presets: ['@babel/preset-flow'],
test: '**/*.js',
},
{
plugins: [
'babel-plugin-typescript-strip-namespaces',
Expand Down
6 changes: 5 additions & 1 deletion e2e/__tests__/coverageReport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion e2e/__tests__/expectAsyncMatcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion e2e/__tests__/failures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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;
Expand Down
55 changes: 21 additions & 34 deletions e2e/__tests__/globalSetup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);
Expand All @@ -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__`,
]);
Expand All @@ -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__`,
]);
Expand All @@ -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}`,
]);
Expand All @@ -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);

Expand All @@ -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',
]);
Expand All @@ -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',
Expand All @@ -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}`,
]);
Expand All @@ -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__`,
]);
Expand Down
49 changes: 18 additions & 31 deletions e2e/__tests__/globalTeardown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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__`,
Expand All @@ -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__`,
]);
Expand All @@ -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}`,
]);
Expand All @@ -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}`]);

Expand All @@ -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}`,
Expand All @@ -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}`,
]);
Expand All @@ -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__`,
]);
Expand Down
3 changes: 3 additions & 0 deletions e2e/coverage-report/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
"setupFiles": [
"<rootDir>/setup.js"
]
},
"devDependencies": {
"@babel/preset-flow": "^7.0.0"
}
}
31 changes: 31 additions & 0 deletions e2e/coverage-report/yarn.lock
Original file line number Diff line number Diff line change
@@ -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"
6 changes: 5 additions & 1 deletion e2e/expect-async-matcher/babel.config.js
Original file line number Diff line number Diff line change
@@ -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'),
});
3 changes: 3 additions & 0 deletions e2e/expect-async-matcher/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"jest": {
"testEnvironment": "node"
},
"devDependencies": {
"@babel/preset-flow": "^7.0.0"
}
}
Loading

0 comments on commit b9d06ad

Please sign in to comment.