Skip to content

Commit a913503

Browse files
committed
Added e2e test
1 parent 088791e commit a913503

File tree

6 files changed

+95
-0
lines changed

6 files changed

+95
-0
lines changed

e2e/__tests__/transform.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,21 @@ describe('babel-jest ignored', () => {
5757
});
5858
});
5959

60+
describe('babel-jest with manual transformer', () => {
61+
const dir = path.resolve(__dirname, '..', 'transform/babel-jest-manual');
62+
63+
beforeEach(() => {
64+
run('yarn', dir);
65+
});
66+
67+
it('runs transpiled code', () => {
68+
// --no-cache because babel can cache stuff and result in false green
69+
const {json} = runWithJson(dir, ['--no-cache']);
70+
expect(json.success).toBe(true);
71+
expect(json.numTotalTests).toBeGreaterThanOrEqual(1);
72+
});
73+
});
74+
6075
// babel-jest is automatically linked at the root because it is a workspace now
6176
// a way to test this in isolation is to move the test suite into a temp folder
6277
describe('no babel-jest', () => {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
'use strict';
9+
10+
require('../foo');
11+
12+
it('strips flowtypes using babel-jest and .babelrc', () => {
13+
const a: string = 'a';
14+
expect(a).toBe('a');
15+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
const someFunction = (): null => null;
9+
10+
module.exports = someFunction();
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"dependencies": {
3+
"@babel/preset-flow": "^7.0.0"
4+
},
5+
"jest": {
6+
"testEnvironment": "node",
7+
"transform": {
8+
"\\.js$": "<rootDir>/transformer.js"
9+
}
10+
}
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
const {createTransformer} = require('babel-jest');
9+
10+
module.exports = createTransformer({
11+
presets: ['@babel/preset-flow'],
12+
root: __dirname,
13+
});
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
"@babel/helper-plugin-utils@^7.0.0":
6+
version "7.0.0"
7+
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0.tgz#bbb3fbee98661c569034237cc03967ba99b4f250"
8+
integrity sha512-CYAOUCARwExnEixLdB6sDm2dIJ/YgEAKDM1MOeMeZu9Ld/bDgVo8aiWrXwcY7OBh+1Ea2uUcVRcxKk0GJvW7QA==
9+
10+
"@babel/plugin-syntax-flow@^7.0.0":
11+
version "7.0.0"
12+
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.0.0.tgz#70638aeaad9ee426bc532e51523cff8ff02f6f17"
13+
integrity sha512-zGcuZWiWWDa5qTZ6iAnpG0fnX/GOu49pGR5PFvkQ9GmKNaSphXQnlNXh/LG20sqWtNrx/eB6krzfEzcwvUyeFA==
14+
dependencies:
15+
"@babel/helper-plugin-utils" "^7.0.0"
16+
17+
"@babel/plugin-transform-flow-strip-types@^7.0.0":
18+
version "7.0.0"
19+
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-flow-strip-types/-/plugin-transform-flow-strip-types-7.0.0.tgz#c40ced34c2783985d90d9f9ac77a13e6fb396a01"
20+
integrity sha512-WhXUNb4It5a19RsgKKbQPrjmy4yWOY1KynpEbNw7bnd1QTcrT/EIl3MJvnGgpgvrKyKbqX7nUNOJfkpLOnoDKA==
21+
dependencies:
22+
"@babel/helper-plugin-utils" "^7.0.0"
23+
"@babel/plugin-syntax-flow" "^7.0.0"
24+
25+
"@babel/preset-flow@^7.0.0":
26+
version "7.0.0"
27+
resolved "https://registry.yarnpkg.com/@babel/preset-flow/-/preset-flow-7.0.0.tgz#afd764835d9535ec63d8c7d4caf1c06457263da2"
28+
integrity sha512-bJOHrYOPqJZCkPVbG1Lot2r5OSsB+iUOaxiHdlOeB1yPWS6evswVHwvkDLZ54WTaTRIk89ds0iHmGZSnxlPejQ==
29+
dependencies:
30+
"@babel/helper-plugin-utils" "^7.0.0"
31+
"@babel/plugin-transform-flow-strip-types" "^7.0.0"

0 commit comments

Comments
 (0)