From ba671b9953fb8c9491fda482f7cf76cedd3b49f9 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Thu, 12 Sep 2019 21:06:23 -0500 Subject: [PATCH] test: refactor some recent jest-tests' configuration, placement, and related babel configuration --- babel.config.js | 6 +++ packages/embark-testing/babel.config.js | 43 +----------------- packages/embark-testing/package.json | 9 +++- .../{src => }/test/testing_test.js | 1 - packages/stack/communication/babel.config.js | 45 +------------------ packages/stack/communication/package.json | 1 - packages/stack/communication/test/index.js | 5 +++ packages/stack/deployment/babel.config.js | 44 +----------------- 8 files changed, 22 insertions(+), 132 deletions(-) rename packages/embark-testing/{src => }/test/testing_test.js (99%) create mode 100644 packages/stack/communication/test/index.js diff --git a/babel.config.js b/babel.config.js index e4c7c26b5..31494a52e 100644 --- a/babel.config.js +++ b/babel.config.js @@ -59,5 +59,11 @@ module.exports = (api) => { return node; } + const test = cloneDeep(node); + + if (env === 'test') { + return test; + } + return {}; }; diff --git a/packages/embark-testing/babel.config.js b/packages/embark-testing/babel.config.js index 8591034d0..325ca2a8e 100644 --- a/packages/embark-testing/babel.config.js +++ b/packages/embark-testing/babel.config.js @@ -1,42 +1 @@ -const cloneDeep = require('lodash.clonedeep'); - -module.exports = api => { - const env = api.env(); - - const base = { - plugins: [ - '@babel/plugin-proposal-class-properties', - [ - '@babel/plugin-transform-runtime', - { - corejs: 2 - } - ] - ], - presets: ['@babel/preset-env'] - }; - - if (env === 'base' || env.startsWith('base:')) { - return base; - } - - const node = cloneDeep(base); - node.presets[0] = [ - node.presets[0], - { - targets: { node: '8.11.3' } - } - ]; - - if (env === 'node' || env.startsWith('node:')) { - return node; - } - - const test = cloneDeep(node); - - if (env === 'test') { - return test; - } - - return {}; -}; +module.exports = require('../../babel.config.js'); diff --git a/packages/embark-testing/package.json b/packages/embark-testing/package.json index 0dee19c47..33427f5c6 100644 --- a/packages/embark-testing/package.json +++ b/packages/embark-testing/package.json @@ -39,7 +39,7 @@ "watch": "run-p watch:*", "watch:build": "npm run build -- --verbose --watch", "// watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch", - "test": "jest dist/test/**/*.js" + "test": "jest" }, "eslintConfig": { "extends": "../../.eslintrc.json" @@ -65,6 +65,13 @@ "tslint": "5.16.0", "typescript": "3.4.5" }, + "jest": { + "collectCoverage": true, + "testEnvironment": "node", + "testMatch": [ + "**/test/**/*.js" + ] + }, "engines": { "node": ">=8.12.0 <12.0.0", "npm": ">=6.4.1", diff --git a/packages/embark-testing/src/test/testing_test.js b/packages/embark-testing/test/testing_test.js similarity index 99% rename from packages/embark-testing/src/test/testing_test.js rename to packages/embark-testing/test/testing_test.js index c9b8b4fdc..a4c7b6107 100644 --- a/packages/embark-testing/src/test/testing_test.js +++ b/packages/embark-testing/test/testing_test.js @@ -7,4 +7,3 @@ describe('Testing', () => { done(); }); }); - diff --git a/packages/stack/communication/babel.config.js b/packages/stack/communication/babel.config.js index 228b2f502..245e0d859 100644 --- a/packages/stack/communication/babel.config.js +++ b/packages/stack/communication/babel.config.js @@ -1,44 +1 @@ -const cloneDeep = require('lodash.clonedeep'); - -module.exports = api => { - const env = api.env(); - - const base = { - plugins: [ - '@babel/plugin-proposal-class-properties', - [ - '@babel/plugin-transform-runtime', - { - corejs: 2 - } - ] - ], - presets: ['@babel/preset-env'] - }; - - if (env === 'base' || env.startsWith('base:')) { - return base; - } - - const node = cloneDeep(base); - node.presets[0] = [ - node.presets[0], - { - targets: { node: '8.11.3' } - } - ]; - - if (env === 'node' || env.startsWith('node:')) { - return node; - } - - const test = cloneDeep(node); - - if (env === 'test') { - return test; - } - - return {}; -}; - - +module.exports = require('../../../babel.config.js'); diff --git a/packages/stack/communication/package.json b/packages/stack/communication/package.json index f094ae29f..9e434e3f2 100644 --- a/packages/stack/communication/package.json +++ b/packages/stack/communication/package.json @@ -83,4 +83,3 @@ ] } } - diff --git a/packages/stack/communication/test/index.js b/packages/stack/communication/test/index.js new file mode 100644 index 000000000..515b22433 --- /dev/null +++ b/packages/stack/communication/test/index.js @@ -0,0 +1,5 @@ +describe('Testing', () => { + it('should have tests', () => { + expect(true).toBe(false); + }); +}); diff --git a/packages/stack/deployment/babel.config.js b/packages/stack/deployment/babel.config.js index c3a8c8c1f..245e0d859 100644 --- a/packages/stack/deployment/babel.config.js +++ b/packages/stack/deployment/babel.config.js @@ -1,43 +1 @@ -const cloneDeep = require('lodash.clonedeep'); - -module.exports = api => { - const env = api.env(); - - const base = { - plugins: [ - '@babel/plugin-proposal-class-properties', - [ - '@babel/plugin-transform-runtime', - { - corejs: 2 - } - ] - ], - presets: ['@babel/preset-env'] - }; - - if (env === 'base' || env.startsWith('base:')) { - return base; - } - - const node = cloneDeep(base); - node.presets[0] = [ - node.presets[0], - { - targets: { node: '8.11.3' } - } - ]; - - if (env === 'node' || env.startsWith('node:')) { - return node; - } - - const test = cloneDeep(node); - - if (env === 'test') { - return test; - } - - return {}; -}; - +module.exports = require('../../../babel.config.js');