Skip to content

Commit

Permalink
fix: update inBand runs failing, reorganize jest configs
Browse files Browse the repository at this point in the history
Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
  • Loading branch information
tunnckoCore committed Oct 2, 2019
1 parent 52213cb commit 684a758
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 29 deletions.
13 changes: 12 additions & 1 deletion @tunnckocore/create-jest-runner/src/createJestRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,18 @@ const createRunner = (runPath, { getExtraOptions } = {}) => {
return runner(baseOptions);
});
})
.then((result) => onResult(test, result))
.then((testResult) => {
if (Array.isArray(testResult)) {
testResult.forEach((result) =>
result.numFailingTests > 0
? onFailure(test, new Error(result.errorMessage))
: onResult(test, result),
);
return;
}

onResult(test, testResult);
})
.catch((err) => onFailure(test, err)),
),
Promise.resolve(),
Expand Down
4 changes: 2 additions & 2 deletions jest-runner.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = {
config: {
presets: [['@tunnckocore/babel-preset', presetOptions]],
comments: false,
sourceMaps: 'both',
sourceMaps: true,
},
outDir: 'dist/main',
},
Expand All @@ -32,7 +32,7 @@ module.exports = {
['@tunnckocore/babel-preset', { ...presetOptions, modules: false }],
],
comments: false,
sourceMaps: 'both',
sourceMaps: true,
},
outDir: 'dist/module',
},
Expand Down
7 changes: 0 additions & 7 deletions jest.config.js

This file was deleted.

8 changes: 5 additions & 3 deletions jest.build.config.js → jest/build.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const utils = require('./@tunnckocore/utils/src');
const path = require('path');
const utils = require('../@tunnckocore/utils/src');

const { exts } = utils.getWorkspacesAndExtensions(__dirname);
const ROOT = path.dirname(__dirname);
const { exts } = utils.getWorkspacesAndExtensions(ROOT);

module.exports = {
rootDir: ROOT,
displayName: 'build',
rootDir: __dirname,
testMatch: [
'<rootDir>/packages/*/src/**/*',
'<rootDir>/@tunnckocore/*/src/**/*',
Expand Down
12 changes: 7 additions & 5 deletions jest.bundle.config.js → jest/bundle.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
const utils = require('./@tunnckocore/utils/src');
const path = require('path');
const utils = require('../@tunnckocore/utils/src');

const { exts } = utils.getWorkspacesAndExtensions(__dirname);
const ROOT = path.dirname(__dirname);
const { exts } = utils.getWorkspacesAndExtensions(ROOT);

module.exports = {
rootDir: ROOT,
displayName: 'bundle',
rootDir: __dirname,
testMatch: [
// '<rootDir>/src/index.ts',
// '<rootDir>/packages/*/src/**/*',
`<rootDir>/@tunnckocore/*/src/index.js`,
`<rootDir>/@tunnckocore/execa/src/index.js`,
// `<rootDir>/src/zzz*`,
],
testPathIgnorePatterns: [
Expand All @@ -18,5 +20,5 @@ module.exports = {
],
// moduleNameMapper: alias,
moduleFileExtensions: exts,
runner: './packages/jest-runner-rollup/src/index.js',
runner: path.join(ROOT, 'packages/jest-runner-rollup/src/index.js'),
};
4 changes: 4 additions & 0 deletions jest/full.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* eslint-disable global-require */
module.exports = {
projects: [require('./lint'), require('./test'), require('./build')],
};
8 changes: 5 additions & 3 deletions jest.lint.config.js → jest/lint.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const utils = require('./@tunnckocore/utils/src');
const path = require('path');
const utils = require('../@tunnckocore/utils/src');

const { alias, exts } = utils.createAliases(__dirname, 'src');
const ROOT = path.dirname(__dirname);
const { alias, exts } = utils.createAliases(ROOT, 'src');

module.exports = {
rootDir: ROOT,
displayName: 'lint',
rootDir: __dirname,
testMatch: [
'<rootDir>/packages/*/src/**/*',
'<rootDir>/@tunnckocore/*/src/**/*',
Expand Down
8 changes: 5 additions & 3 deletions jest.test.config.js → jest/test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const utils = require('./@tunnckocore/utils/src');
const path = require('path');
const utils = require('../@tunnckocore/utils/src');

const { alias } = utils.createAliases(__dirname, 'src');
const ROOT = path.dirname(__dirname);
const { alias } = utils.createAliases(ROOT, 'src');

module.exports = {
rootDir: ROOT,
displayName: 'test',
rootDir: __dirname,
testMatch: [
'<rootDir>/packages/*/test/**/*',
'<rootDir>/@tunnckocore/*/test/**/*',
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"clean:fresh": "lerna clean -y && rm -rf node_modules",
"clean:dist": "rm -rf packages/*/dist @tunnckocore/*/dist",
"pre-commit": "yarn jest:all || (yarn resque && yarn jest:all)",
"jest:all": "jest -c jest.config.js",
"lint": "jest -c jest.lint.config.js",
"test": "jest -c jest.test.config.js",
"build": "jest -c jest.build.config.js",
"bundle": "jest -c jest.bundle.config.js",
"jest:all": "jest -c jest/full.js",
"lint": "jest -c jest/lint.js",
"test": "jest -c jest/test.js",
"build": "jest -c jest/build.js",
"bundle": "jest -c jest/bundle.js",
"release": "lerna version && lerna publish from-package",
"cr": "node create-package.js",
"fmt": "prettier '**/*' --write --check",
Expand Down

0 comments on commit 684a758

Please sign in to comment.