Skip to content

Commit

Permalink
Added e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
rubennorte committed Feb 21, 2019
1 parent 088791e commit 2e552a3
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 0 deletions.
15 changes: 15 additions & 0 deletions e2e/__tests__/transform.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ describe('babel-jest ignored', () => {
});
});

describe('babel-jest with manual transformer', () => {
const dir = path.resolve(__dirname, '..', 'transform/babel-jest-manual');

beforeEach(() => {
run('yarn', dir);
});

it('runs transpiled code', () => {
// --no-cache because babel can cache stuff and result in false green
const {json} = runWithJson(dir, ['--no-cache']);
expect(json.success).toBe(true);
expect(json.numTotalTests).toBeGreaterThanOrEqual(1);
});
});

// babel-jest is automatically linked at the root because it is a workspace now
// a way to test this in isolation is to move the test suite into a temp folder
describe('no babel-jest', () => {
Expand Down
15 changes: 15 additions & 0 deletions e2e/transform/babel-jest-manual/__tests__/babelJest.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

require('../foo');

it('strips flowtypes using babel-jest and .babelrc', () => {
const a: string = 'a';
expect(a).toBe('a');
});
10 changes: 10 additions & 0 deletions e2e/transform/babel-jest-manual/foo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

const someFunction = (): null => null;

module.exports = someFunction();
11 changes: 11 additions & 0 deletions e2e/transform/babel-jest-manual/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"dependencies": {
"@babel/preset-flow": "^7.0.0"
},
"jest": {
"testEnvironment": "node",
"transform": {
"\\.js$": "<rootDir>/transformer.js"
}
}
}
6 changes: 6 additions & 0 deletions e2e/transform/babel-jest-manual/transformer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const {createTransformer} = require('babel-jest');

module.exports = createTransformer({
presets: ['@babel/preset-flow'],
root: __dirname,
});
31 changes: 31 additions & 0 deletions e2e/transform/babel-jest-manual/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.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.0.0.tgz#70638aeaad9ee426bc532e51523cff8ff02f6f17"
integrity sha512-zGcuZWiWWDa5qTZ6iAnpG0fnX/GOu49pGR5PFvkQ9GmKNaSphXQnlNXh/LG20sqWtNrx/eB6krzfEzcwvUyeFA==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"

"@babel/plugin-transform-flow-strip-types@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-flow-strip-types/-/plugin-transform-flow-strip-types-7.0.0.tgz#c40ced34c2783985d90d9f9ac77a13e6fb396a01"
integrity sha512-WhXUNb4It5a19RsgKKbQPrjmy4yWOY1KynpEbNw7bnd1QTcrT/EIl3MJvnGgpgvrKyKbqX7nUNOJfkpLOnoDKA==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-syntax-flow" "^7.0.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"

0 comments on commit 2e552a3

Please sign in to comment.