From 4d2ebc414753f466f7fbc70e13128fe8e57badaf Mon Sep 17 00:00:00 2001 From: Bradford Lemley Date: Mon, 4 Feb 2019 10:29:31 -0700 Subject: [PATCH] Add tests for a few other babel config methods --- e2e/__tests__/multiProjectRunner.test.js | 37 ++++++++++++++----- e2e/multi-project-babel/bar/bar.test.js | 6 --- e2e/multi-project-babel/foo/foo.test.js | 6 --- e2e/multi-project-babel/package.json | 9 +++-- .../.babelrc.js => prj-1/babel.config.js} | 0 .../{bar/bar.js => prj-1/index.js} | 0 e2e/multi-project-babel/prj-1/index.test.js | 6 +++ .../{bar => prj-1}/package.json | 0 .../{foo => prj-2}/.babelrc.js | 0 .../{foo/foo.js => prj-2/index.js} | 0 e2e/multi-project-babel/prj-2/index.test.js | 6 +++ .../{foo => prj-2}/package.json | 0 e2e/multi-project-babel/prj-3/package.json | 5 +++ .../prj-3/src/babel.config.js | 4 ++ e2e/multi-project-babel/prj-3/src/index.js | 2 + .../prj-3/src/index.test.js | 6 +++ e2e/multi-project-babel/prj-4/.babelrc.js | 4 ++ e2e/multi-project-babel/prj-4/package.json | 5 +++ e2e/multi-project-babel/prj-4/src/index.js | 2 + .../prj-4/src/index.test.js | 6 +++ e2e/multi-project-babel/prj-5/.babelrc.js | 4 ++ e2e/multi-project-babel/prj-5/package.json | 5 +++ e2e/multi-project-babel/prj-5/src/index.js | 2 + .../prj-5/src/index.test.js | 6 +++ 24 files changed, 97 insertions(+), 24 deletions(-) delete mode 100644 e2e/multi-project-babel/bar/bar.test.js delete mode 100644 e2e/multi-project-babel/foo/foo.test.js rename e2e/multi-project-babel/{bar/.babelrc.js => prj-1/babel.config.js} (100%) rename e2e/multi-project-babel/{bar/bar.js => prj-1/index.js} (100%) create mode 100644 e2e/multi-project-babel/prj-1/index.test.js rename e2e/multi-project-babel/{bar => prj-1}/package.json (100%) rename e2e/multi-project-babel/{foo => prj-2}/.babelrc.js (100%) rename e2e/multi-project-babel/{foo/foo.js => prj-2/index.js} (100%) create mode 100644 e2e/multi-project-babel/prj-2/index.test.js rename e2e/multi-project-babel/{foo => prj-2}/package.json (100%) create mode 100644 e2e/multi-project-babel/prj-3/package.json create mode 100644 e2e/multi-project-babel/prj-3/src/babel.config.js create mode 100644 e2e/multi-project-babel/prj-3/src/index.js create mode 100644 e2e/multi-project-babel/prj-3/src/index.test.js create mode 100644 e2e/multi-project-babel/prj-4/.babelrc.js create mode 100644 e2e/multi-project-babel/prj-4/package.json create mode 100644 e2e/multi-project-babel/prj-4/src/index.js create mode 100644 e2e/multi-project-babel/prj-4/src/index.test.js create mode 100644 e2e/multi-project-babel/prj-5/.babelrc.js create mode 100644 e2e/multi-project-babel/prj-5/package.json create mode 100644 e2e/multi-project-babel/prj-5/src/index.js create mode 100644 e2e/multi-project-babel/prj-5/src/index.test.js diff --git a/e2e/__tests__/multiProjectRunner.test.js b/e2e/__tests__/multiProjectRunner.test.js index da82fa10235a..8f41f18e2e3f 100644 --- a/e2e/__tests__/multiProjectRunner.test.js +++ b/e2e/__tests__/multiProjectRunner.test.js @@ -499,20 +499,39 @@ describe("doesn't bleed module file extensions resolution with multiple workers" }); describe('Babel config in individual project works in multi-project', () => { - it('Transpiles when running bar individually', () => { - const result = runJest('multi-project-babel/bar'); - expect(result.stderr).toMatch('PASS ./bar.test.js'); + it('Prj-1 works individually', () => { + const result = runJest('multi-project-babel/prj-1'); + expect(result.stderr).toMatch('PASS ./index.test.js'); expect(result.status).toBe(0); }); - it('Transpiles when running foo individually', () => { - const result = runJest('multi-project-babel/foo'); - expect(result.stderr).toMatch('PASS ./foo.test.js'); + it('Prj-2 works individually', () => { + const result = runJest('multi-project-babel/prj-2'); + expect(result.stderr).toMatch('PASS ./index.test.js'); expect(result.status).toBe(0); }); - it('Transpiles when running from multiproject', () => { + it('Prj-3 works individually', () => { + const result = runJest('multi-project-babel/prj-3'); + expect(result.stderr).toMatch('PASS src/index.test.js'); + expect(result.status).toBe(0); + }); + it('Prj-4 works individually', () => { + const result = runJest('multi-project-babel/prj-4'); + expect(result.stderr).toMatch('PASS src/index.test.js'); + expect(result.status).toBe(0); + }); + it('Prj-5 works individually', () => { + const result = runJest('multi-project-babel/prj-5'); + expect(result.stderr).toMatch('PASS src/index.test.js'); + expect(result.status).toBe(0); + }); + it('All project work when running from multiproject', () => { const result = runJest('multi-project-babel'); - expect(result.stderr).toMatch('PASS bar/bar.test.js'); - expect(result.stderr).toMatch('PASS foo/foo.test.js'); + expect(result.stderr).toMatch('PASS prj-1/index.test.js'); + expect(result.stderr).toMatch('PASS prj-2/index.test.js'); + expect(result.stderr).toMatch('PASS prj-3/src/index.test.js'); + expect(result.stderr).toMatch('PASS prj-4/src/index.test.js'); + expect(result.stderr).toMatch('PASS prj-5/src/index.test.js'); + expect(result.stderr).toMatch('PASS prj-3/src/index.test.js'); expect(result.status).toBe(0); }); }); diff --git a/e2e/multi-project-babel/bar/bar.test.js b/e2e/multi-project-babel/bar/bar.test.js deleted file mode 100644 index 922937210429..000000000000 --- a/e2e/multi-project-babel/bar/bar.test.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -const bar = require('./bar'); - -it('Bar transpiles', () => { - expect(bar('test')).toBe('test'); -}); diff --git a/e2e/multi-project-babel/foo/foo.test.js b/e2e/multi-project-babel/foo/foo.test.js deleted file mode 100644 index 929edf4cd0c2..000000000000 --- a/e2e/multi-project-babel/foo/foo.test.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -const foo = require('./foo'); - -it('Foo transpiles', () => { - expect(foo('test')).toBe('test'); -}); diff --git a/e2e/multi-project-babel/package.json b/e2e/multi-project-babel/package.json index 0c679cc796ea..c51f8db5ccfa 100644 --- a/e2e/multi-project-babel/package.json +++ b/e2e/multi-project-babel/package.json @@ -2,11 +2,14 @@ "jest": { "projects": [ { - "rootDir": "/foo" + "rootDir": "/prj-1" }, { - "rootDir": "/bar" - } + "rootDir": "/prj-2" + }, + "/prj-3", + "/prj-4", + "/prj-5" ] } } diff --git a/e2e/multi-project-babel/bar/.babelrc.js b/e2e/multi-project-babel/prj-1/babel.config.js similarity index 100% rename from e2e/multi-project-babel/bar/.babelrc.js rename to e2e/multi-project-babel/prj-1/babel.config.js diff --git a/e2e/multi-project-babel/bar/bar.js b/e2e/multi-project-babel/prj-1/index.js similarity index 100% rename from e2e/multi-project-babel/bar/bar.js rename to e2e/multi-project-babel/prj-1/index.js diff --git a/e2e/multi-project-babel/prj-1/index.test.js b/e2e/multi-project-babel/prj-1/index.test.js new file mode 100644 index 000000000000..342d17879557 --- /dev/null +++ b/e2e/multi-project-babel/prj-1/index.test.js @@ -0,0 +1,6 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +const f = require('./'); + +it('Transpiles', () => { + expect(f('test')).toBe('test'); +}); diff --git a/e2e/multi-project-babel/bar/package.json b/e2e/multi-project-babel/prj-1/package.json similarity index 100% rename from e2e/multi-project-babel/bar/package.json rename to e2e/multi-project-babel/prj-1/package.json diff --git a/e2e/multi-project-babel/foo/.babelrc.js b/e2e/multi-project-babel/prj-2/.babelrc.js similarity index 100% rename from e2e/multi-project-babel/foo/.babelrc.js rename to e2e/multi-project-babel/prj-2/.babelrc.js diff --git a/e2e/multi-project-babel/foo/foo.js b/e2e/multi-project-babel/prj-2/index.js similarity index 100% rename from e2e/multi-project-babel/foo/foo.js rename to e2e/multi-project-babel/prj-2/index.js diff --git a/e2e/multi-project-babel/prj-2/index.test.js b/e2e/multi-project-babel/prj-2/index.test.js new file mode 100644 index 000000000000..342d17879557 --- /dev/null +++ b/e2e/multi-project-babel/prj-2/index.test.js @@ -0,0 +1,6 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +const f = require('./'); + +it('Transpiles', () => { + expect(f('test')).toBe('test'); +}); diff --git a/e2e/multi-project-babel/foo/package.json b/e2e/multi-project-babel/prj-2/package.json similarity index 100% rename from e2e/multi-project-babel/foo/package.json rename to e2e/multi-project-babel/prj-2/package.json diff --git a/e2e/multi-project-babel/prj-3/package.json b/e2e/multi-project-babel/prj-3/package.json new file mode 100644 index 000000000000..2b9231f5dcc3 --- /dev/null +++ b/e2e/multi-project-babel/prj-3/package.json @@ -0,0 +1,5 @@ +{ + "jest": { + "rootDir": "src" + } +} diff --git a/e2e/multi-project-babel/prj-3/src/babel.config.js b/e2e/multi-project-babel/prj-3/src/babel.config.js new file mode 100644 index 000000000000..eef9b61187fb --- /dev/null +++ b/e2e/multi-project-babel/prj-3/src/babel.config.js @@ -0,0 +1,4 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +module.exports = { + presets: ['@babel/preset-flow'], +}; diff --git a/e2e/multi-project-babel/prj-3/src/index.js b/e2e/multi-project-babel/prj-3/src/index.js new file mode 100644 index 000000000000..7e9de98e4811 --- /dev/null +++ b/e2e/multi-project-babel/prj-3/src/index.js @@ -0,0 +1,2 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +module.exports = (text: string) => text; diff --git a/e2e/multi-project-babel/prj-3/src/index.test.js b/e2e/multi-project-babel/prj-3/src/index.test.js new file mode 100644 index 000000000000..342d17879557 --- /dev/null +++ b/e2e/multi-project-babel/prj-3/src/index.test.js @@ -0,0 +1,6 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +const f = require('./'); + +it('Transpiles', () => { + expect(f('test')).toBe('test'); +}); diff --git a/e2e/multi-project-babel/prj-4/.babelrc.js b/e2e/multi-project-babel/prj-4/.babelrc.js new file mode 100644 index 000000000000..eef9b61187fb --- /dev/null +++ b/e2e/multi-project-babel/prj-4/.babelrc.js @@ -0,0 +1,4 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +module.exports = { + presets: ['@babel/preset-flow'], +}; diff --git a/e2e/multi-project-babel/prj-4/package.json b/e2e/multi-project-babel/prj-4/package.json new file mode 100644 index 000000000000..2b9231f5dcc3 --- /dev/null +++ b/e2e/multi-project-babel/prj-4/package.json @@ -0,0 +1,5 @@ +{ + "jest": { + "rootDir": "src" + } +} diff --git a/e2e/multi-project-babel/prj-4/src/index.js b/e2e/multi-project-babel/prj-4/src/index.js new file mode 100644 index 000000000000..7e9de98e4811 --- /dev/null +++ b/e2e/multi-project-babel/prj-4/src/index.js @@ -0,0 +1,2 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +module.exports = (text: string) => text; diff --git a/e2e/multi-project-babel/prj-4/src/index.test.js b/e2e/multi-project-babel/prj-4/src/index.test.js new file mode 100644 index 000000000000..342d17879557 --- /dev/null +++ b/e2e/multi-project-babel/prj-4/src/index.test.js @@ -0,0 +1,6 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +const f = require('./'); + +it('Transpiles', () => { + expect(f('test')).toBe('test'); +}); diff --git a/e2e/multi-project-babel/prj-5/.babelrc.js b/e2e/multi-project-babel/prj-5/.babelrc.js new file mode 100644 index 000000000000..eef9b61187fb --- /dev/null +++ b/e2e/multi-project-babel/prj-5/.babelrc.js @@ -0,0 +1,4 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +module.exports = { + presets: ['@babel/preset-flow'], +}; diff --git a/e2e/multi-project-babel/prj-5/package.json b/e2e/multi-project-babel/prj-5/package.json new file mode 100644 index 000000000000..2b9231f5dcc3 --- /dev/null +++ b/e2e/multi-project-babel/prj-5/package.json @@ -0,0 +1,5 @@ +{ + "jest": { + "rootDir": "src" + } +} diff --git a/e2e/multi-project-babel/prj-5/src/index.js b/e2e/multi-project-babel/prj-5/src/index.js new file mode 100644 index 000000000000..7e9de98e4811 --- /dev/null +++ b/e2e/multi-project-babel/prj-5/src/index.js @@ -0,0 +1,2 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +module.exports = (text: string) => text; diff --git a/e2e/multi-project-babel/prj-5/src/index.test.js b/e2e/multi-project-babel/prj-5/src/index.test.js new file mode 100644 index 000000000000..342d17879557 --- /dev/null +++ b/e2e/multi-project-babel/prj-5/src/index.test.js @@ -0,0 +1,6 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +const f = require('./'); + +it('Transpiles', () => { + expect(f('test')).toBe('test'); +});