Skip to content

Commit ba8a7ac

Browse files
committed
fix: no build step for *jest-runner* packages
Signed-off-by: Charlike Mike Reagent <[email protected]>
1 parent a365167 commit ba8a7ac

File tree

20 files changed

+133
-118
lines changed

20 files changed

+133
-118
lines changed

@tunnckocore/create-jest-runner/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
"homepage": "https://github.com/tunnckoCore/opensource",
77
"license": "MPL-2.0",
88
"licenseStart": 2019,
9-
"main": "dist/main/index.js",
10-
"module": "dist/module/index.js",
11-
"types": "dist/types/index.d.ts",
9+
"main": "src/index.js",
10+
"types": "index.d.ts",
1211
"scripts": {},
1312
"publishConfig": {
1413
"access": "public",
@@ -33,7 +32,8 @@
3332
"jest": "^24.0.0"
3433
},
3534
"files": [
36-
"dist",
35+
"src",
36+
"index.d.ts",
3737
"generator"
3838
],
3939
"bin": {

@tunnckocore/create-jest-runner/src/createJestRunner.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
/* eslint-disable promise/prefer-await-to-then */
44
/* eslint-disable no-underscore-dangle */
55
/* eslint-disable max-classes-per-file */
6-
import throat from 'throat';
7-
import Worker from 'jest-worker';
6+
const throat = require('throat');
7+
const JestWorker = require('jest-worker').default;
88

99
class CancelRunError extends Error {
1010
constructor(message) {
@@ -13,7 +13,7 @@ class CancelRunError extends Error {
1313
}
1414
}
1515

16-
const createRunner = (runPath, { getExtraOptions } = {}) => {
16+
module.exports = function createRunner(runPath, { getExtraOptions } = {}) {
1717
class BaseTestRunner {
1818
constructor(globalConfig) {
1919
this._globalConfig = globalConfig;
@@ -103,7 +103,7 @@ const createRunner = (runPath, { getExtraOptions } = {}) => {
103103
onFailure,
104104
options,
105105
) {
106-
const worker = new Worker(runPath, {
106+
const worker = new JestWorker(runPath, {
107107
exposedMethods: ['default'],
108108
numWorkers: this._globalConfig.maxWorkers,
109109
forkOptions: { stdio: 'inherit' },
@@ -183,5 +183,3 @@ const createRunner = (runPath, { getExtraOptions } = {}) => {
183183

184184
return BaseTestRunner;
185185
};
186-
187-
export default createRunner;
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import toTestResult from './toTestResult';
1+
const toTestResult = require('./toTestResult');
22

3-
const fail = ({ start, end, test, errorMessage }) =>
4-
toTestResult({
3+
module.exports = function fail({ start, end, test, errorMessage }) {
4+
return toTestResult({
55
errorMessage: errorMessage || test.errorMessage,
66
stats: {
77
failures: 1,
@@ -14,5 +14,4 @@ const fail = ({ start, end, test, errorMessage }) =>
1414
tests: [{ duration: end - start, ...test }],
1515
jestTestPath: test.path,
1616
});
17-
18-
export default fail;
17+
};
Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
1-
export { default as createJestRunner } from './createJestRunner';
2-
export { default as fail } from './fail';
3-
export { default as pass } from './pass';
4-
export { default as skip } from './skip';
5-
export { default as todo } from './todo';
1+
const createJestRunner = require('./createJestRunner');
2+
const pass = require('./pass');
3+
const fail = require('./fail');
4+
const skip = require('./skip');
5+
const todo = require('./todo');
6+
7+
exports.default = {
8+
createJestRunner,
9+
pass,
10+
fail,
11+
skip,
12+
todo,
13+
};
14+
15+
exports.createJestRunner = createJestRunner;
16+
exports.pass = pass;
17+
exports.fail = fail;
18+
exports.skip = skip;
19+
exports.todo = todo;
20+
21+
// eslint-disable-next-line no-underscore-dangle
22+
const ___exportsWithoutDefault = Object.keys(exports)
23+
.filter((x) => x !== 'default')
24+
.reduce((acc, key) => {
25+
acc[key] = exports[key];
26+
return acc;
27+
}, {});
28+
29+
module.exports = Object.assign(exports.default, ___exportsWithoutDefault);
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import toTestResult from './toTestResult';
1+
const toTestResult = require('./toTestResult');
22

3-
const pass = ({ start, end, test }) =>
4-
toTestResult({
3+
module.exports = function pass({ start, end, test }) {
4+
return toTestResult({
55
stats: {
66
failures: 0,
77
pending: 0,
@@ -13,5 +13,4 @@ const pass = ({ start, end, test }) =>
1313
tests: [{ duration: end - start, ...test }],
1414
jestTestPath: test.path,
1515
});
16-
17-
export default pass;
16+
};
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import toTestResult from './toTestResult';
1+
const toTestResult = require('./toTestResult');
22

3-
const skip = ({ start, end, test }) =>
4-
toTestResult({
3+
module.exports = function skip({ start, end, test }) {
4+
return toTestResult({
55
stats: {
66
failures: 0,
77
pending: 1,
@@ -14,5 +14,4 @@ const skip = ({ start, end, test }) =>
1414
tests: [{ duration: end - start, ...test }],
1515
jestTestPath: test.path,
1616
});
17-
18-
export default skip;
17+
};
Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
const toTestResult = ({
1+
module.exports = function toTestResult({
22
stats,
33
skipped,
44
errorMessage,
55
tests,
66
jestTestPath,
7-
}) => ({
8-
console: null,
9-
failureMessage: errorMessage,
10-
numFailingTests: stats.failures,
11-
numPassingTests: stats.passes,
12-
numPendingTests: stats.pending,
13-
numTodoTests: stats.todo,
14-
perfStats: {
15-
end: new Date(stats.end).getTime(),
16-
start: new Date(stats.start).getTime(),
17-
},
18-
skipped,
19-
snapshot: {
20-
added: 0,
21-
fileDeleted: false,
22-
matched: 0,
23-
unchecked: 0,
24-
unmatched: 0,
25-
updated: 0,
26-
},
27-
sourceMaps: {},
28-
testExecError: null,
29-
testFilePath: jestTestPath,
30-
testResults: tests.map((test) => ({
31-
ancestorTitles: [],
32-
duration: test.duration,
33-
failureMessages: [test.errorMessage],
34-
fullName: test.testPath,
35-
numPassingAsserts: test.errorMessage ? 1 : 0,
36-
status: test.errorMessage ? 'failed' : 'passed',
37-
title: test.title || '',
38-
})),
39-
});
40-
41-
export default toTestResult;
7+
}) {
8+
return {
9+
console: null,
10+
failureMessage: errorMessage,
11+
numFailingTests: stats.failures,
12+
numPassingTests: stats.passes,
13+
numPendingTests: stats.pending,
14+
numTodoTests: stats.todo,
15+
perfStats: {
16+
end: new Date(stats.end).getTime(),
17+
start: new Date(stats.start).getTime(),
18+
},
19+
skipped,
20+
snapshot: {
21+
added: 0,
22+
fileDeleted: false,
23+
matched: 0,
24+
unchecked: 0,
25+
unmatched: 0,
26+
updated: 0,
27+
},
28+
sourceMaps: {},
29+
testExecError: null,
30+
testFilePath: jestTestPath,
31+
testResults: tests.map((test) => ({
32+
ancestorTitles: [],
33+
duration: test.duration,
34+
failureMessages: [test.errorMessage],
35+
fullName: test.testPath,
36+
numPassingAsserts: test.errorMessage ? 1 : 0,
37+
status: test.errorMessage ? 'failed' : 'passed',
38+
title: test.title || '',
39+
})),
40+
};
41+
};
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import toTestResult from './toTestResult';
1+
const toTestResult = require('./toTestResult');
22

3-
const todo = ({ start, end, test }) =>
4-
toTestResult({
3+
module.exports = function todo({ start, end, test }) {
4+
return toTestResult({
55
stats: {
66
failures: 0,
77
pending: 0,
@@ -13,5 +13,4 @@ const todo = ({ start, end, test }) =>
1313
tests: [{ duration: end - start, ...test }],
1414
jestTestPath: test.path,
1515
});
16-
17-
export default todo;
16+
};

@tunnckocore/create-jest-runner/test/support/runJest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function normalize(output) {
1616
.replace(/\s+\n/g, '\n');
1717
}
1818

19-
export default function runJest(project, options = []) {
19+
module.exports = function runJest(project, options = []) {
2020
// eslint-disable-next-line no-undef
2121
jest.setTimeout(15000);
2222

@@ -38,4 +38,4 @@ export default function runJest(project, options = []) {
3838
({ stdout, stderr }) =>
3939
`${stripColor(normalize(stderr))}\n${stripColor(normalize(stdout))}`,
4040
);
41-
}
41+
};

@tunnckocore/jest-runner-babel/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
"homepage": "https://github.com/tunnckoCore/opensource",
77
"license": "MPL-2.0",
88
"licenseStart": 2019,
9-
"main": "dist/main/index.js",
10-
"module": "dist/module/index.js",
11-
"types": "dist/types/index.d.ts",
9+
"main": "src/index.js",
10+
"types": "index.d.ts",
1211
"scripts": {},
1312
"publishConfig": {
1413
"access": "public",
@@ -28,7 +27,8 @@
2827
"cosmiconfig": "^5.2.1"
2928
},
3029
"files": [
31-
"dist"
30+
"src",
31+
"index.d.ts"
3232
],
3333
"keywords": [
3434
"tunnckocorehq",

0 commit comments

Comments
 (0)