test: refactor some recent jest-tests' configuration, placement, and related babel configuration

This commit is contained in:
Michael Bradley, Jr 2019-09-12 21:06:23 -05:00 committed by Michael Bradley
parent 0050adb4bb
commit ba671b9953
8 changed files with 22 additions and 132 deletions

View File

@ -59,5 +59,11 @@ module.exports = (api) => {
return node; return node;
} }
const test = cloneDeep(node);
if (env === 'test') {
return test;
}
return {}; return {};
}; };

View File

@ -1,42 +1 @@
const cloneDeep = require('lodash.clonedeep'); module.exports = require('../../babel.config.js');
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 {};
};

View File

@ -39,7 +39,7 @@
"watch": "run-p watch:*", "watch": "run-p watch:*",
"watch:build": "npm run build -- --verbose --watch", "watch:build": "npm run build -- --verbose --watch",
"// watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch", "// watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch",
"test": "jest dist/test/**/*.js" "test": "jest"
}, },
"eslintConfig": { "eslintConfig": {
"extends": "../../.eslintrc.json" "extends": "../../.eslintrc.json"
@ -65,6 +65,13 @@
"tslint": "5.16.0", "tslint": "5.16.0",
"typescript": "3.4.5" "typescript": "3.4.5"
}, },
"jest": {
"collectCoverage": true,
"testEnvironment": "node",
"testMatch": [
"**/test/**/*.js"
]
},
"engines": { "engines": {
"node": ">=8.12.0 <12.0.0", "node": ">=8.12.0 <12.0.0",
"npm": ">=6.4.1", "npm": ">=6.4.1",

View File

@ -7,4 +7,3 @@ describe('Testing', () => {
done(); done();
}); });
}); });

View File

@ -1,44 +1 @@
const cloneDeep = require('lodash.clonedeep'); module.exports = require('../../../babel.config.js');
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 {};
};

View File

@ -83,4 +83,3 @@
] ]
} }
} }

View File

@ -0,0 +1,5 @@
describe('Testing', () => {
it('should have tests', () => {
expect(true).toBe(false);
});
});

View File

@ -1,43 +1 @@
const cloneDeep = require('lodash.clonedeep'); module.exports = require('../../../babel.config.js');
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 {};
};