@modern-js/plugin-testing 1.3.3 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -0
- package/dist/js/modern/cli/index.js +83 -29
- package/dist/js/modern/cli/test.js +5 -35
- package/dist/js/modern/constant.js +1 -1
- package/dist/js/modern/runtime-testing/app.js +2 -2
- package/dist/js/modern/runtime-testing/reduck.js +2 -2
- package/dist/js/node/cli/index.js +91 -31
- package/dist/js/node/cli/test.js +5 -39
- package/dist/js/node/constant.js +3 -3
- package/dist/js/node/runtime-testing/app.js +1 -1
- package/dist/js/node/runtime-testing/reduck.js +1 -1
- package/dist/js/treeshaking/cli/index.js +117 -38
- package/dist/js/treeshaking/cli/test.js +11 -59
- package/dist/js/treeshaking/constant.js +1 -1
- package/dist/js/treeshaking/runtime-testing/app.js +2 -2
- package/dist/js/treeshaking/runtime-testing/reduck.js +2 -2
- package/dist/types/cli/index.d.ts +5 -1
- package/dist/types/cli/test.d.ts +3 -10
- package/dist/types/constant.d.ts +1 -1
- package/dist/types/runtime-testing/app.d.ts +1 -1
- package/dist/types/runtime-testing/resolvePlugins.d.ts +1 -1
- package/jest.config.js +0 -1
- package/package.json +19 -9
- package/{dist/js/modern/cli/plugins/modern.test.js → tests/merge-config.test.ts} +22 -25
- package/type.d.ts +0 -11
- package/dist/js/modern/cli/plugins/modern.js +0 -43
- package/dist/js/node/cli/plugins/modern.js +0 -57
- package/dist/js/node/cli/plugins/modern.test.js +0 -60
- package/dist/js/treeshaking/cli/plugins/modern.js +0 -70
- package/dist/js/treeshaking/cli/plugins/modern.test.js +0 -53
- package/dist/types/cli/plugins/modern.d.ts +0 -6
- package/dist/types/cli/plugins/modern.test.d.ts +0 -1
@@ -1,60 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var _modern = require("./modern");
|
4
|
-
|
5
|
-
describe('modern plugin', () => {
|
6
|
-
test('mergeUserJestConfig support object', () => {
|
7
|
-
const testUtils = {
|
8
|
-
_jestConfig: {
|
9
|
-
a: 1
|
10
|
-
},
|
11
|
-
|
12
|
-
get jestConfig() {
|
13
|
-
return this._jestConfig;
|
14
|
-
},
|
15
|
-
|
16
|
-
testConfig: {
|
17
|
-
jest: {
|
18
|
-
b: 1
|
19
|
-
}
|
20
|
-
},
|
21
|
-
|
22
|
-
mergeJestConfig(config) {
|
23
|
-
Object.assign(this._jestConfig, config);
|
24
|
-
}
|
25
|
-
|
26
|
-
};
|
27
|
-
(0, _modern.mergeUserJestConfig)(testUtils);
|
28
|
-
expect(testUtils.jestConfig).toEqual({
|
29
|
-
a: 1,
|
30
|
-
b: 1
|
31
|
-
});
|
32
|
-
});
|
33
|
-
test('mergeUserJestConfig support function', () => {
|
34
|
-
const testUtils = {
|
35
|
-
_jestConfig: {
|
36
|
-
a: 1
|
37
|
-
},
|
38
|
-
|
39
|
-
get jestConfig() {
|
40
|
-
return this._jestConfig;
|
41
|
-
},
|
42
|
-
|
43
|
-
testConfig: {
|
44
|
-
jest: jestConfig => {
|
45
|
-
jestConfig.b = 1;
|
46
|
-
}
|
47
|
-
},
|
48
|
-
|
49
|
-
mergeJestConfig(config) {
|
50
|
-
Object.assign(this._jestConfig, config);
|
51
|
-
}
|
52
|
-
|
53
|
-
};
|
54
|
-
(0, _modern.mergeUserJestConfig)(testUtils);
|
55
|
-
expect(testUtils.jestConfig).toEqual({
|
56
|
-
a: 1,
|
57
|
-
b: 1
|
58
|
-
});
|
59
|
-
});
|
60
|
-
});
|
@@ -1,70 +0,0 @@
|
|
1
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
2
|
-
|
3
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
4
|
-
|
5
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
6
|
-
|
7
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
8
|
-
|
9
|
-
import { createPlugin, getModuleNameMapper } from '@modern-js/testing';
|
10
|
-
import { modernjs_config_key } from "../../constant";
|
11
|
-
export var mergeUserJestConfig = /*#__PURE__*/function () {
|
12
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(testUtils) {
|
13
|
-
var resolveJestConfig;
|
14
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
15
|
-
while (1) {
|
16
|
-
switch (_context.prev = _context.next) {
|
17
|
-
case 0:
|
18
|
-
resolveJestConfig = testUtils.testConfig.jest;
|
19
|
-
|
20
|
-
if (resolveJestConfig && typeof resolveJestConfig !== 'function') {
|
21
|
-
testUtils.mergeJestConfig(resolveJestConfig);
|
22
|
-
}
|
23
|
-
|
24
|
-
if (!(typeof resolveJestConfig === 'function')) {
|
25
|
-
_context.next = 5;
|
26
|
-
break;
|
27
|
-
}
|
28
|
-
|
29
|
-
_context.next = 5;
|
30
|
-
return resolveJestConfig(testUtils.jestConfig);
|
31
|
-
|
32
|
-
case 5:
|
33
|
-
case "end":
|
34
|
-
return _context.stop();
|
35
|
-
}
|
36
|
-
}
|
37
|
-
}, _callee);
|
38
|
-
}));
|
39
|
-
|
40
|
-
return function mergeUserJestConfig(_x) {
|
41
|
-
return _ref.apply(this, arguments);
|
42
|
-
};
|
43
|
-
}();
|
44
|
-
export default (function (webpackConfig, userConfig, pwd) {
|
45
|
-
return createPlugin(function () {
|
46
|
-
var _webpackConfig$resolv = webpackConfig.resolve.alias,
|
47
|
-
alias = _webpackConfig$resolv === void 0 ? {} : _webpackConfig$resolv;
|
48
|
-
return {
|
49
|
-
jestConfig: function jestConfig(utils, next) {
|
50
|
-
utils.mergeJestConfig({
|
51
|
-
globals: _defineProperty({}, modernjs_config_key, userConfig),
|
52
|
-
moduleNameMapper: getModuleNameMapper(alias),
|
53
|
-
testEnvironment: 'jsdom',
|
54
|
-
resolver: require.resolve("../resolver")
|
55
|
-
});
|
56
|
-
utils.setJestConfig({
|
57
|
-
rootDir: pwd || process.cwd(),
|
58
|
-
// todo: diffrent test root for diffrent solutions
|
59
|
-
// testMatch: [`<rootDir>/(src|tests|electron)/**/*.test.[jt]s?(x)`],
|
60
|
-
// testMatch bug on windows, issue: https://github.com/facebook/jest/issues/7914
|
61
|
-
testMatch: ["<rootDir>/src/**/*.test.[jt]s?(x)", "<rootDir>/tests/**/*.test.[jt]s?(x)", "<rootDir>/electron/**/*.test.[jt]s?(x)"]
|
62
|
-
});
|
63
|
-
mergeUserJestConfig(utils);
|
64
|
-
return next(utils);
|
65
|
-
}
|
66
|
-
};
|
67
|
-
}, {
|
68
|
-
name: '@modern-js/testing-plugin-modern'
|
69
|
-
});
|
70
|
-
});
|
@@ -1,53 +0,0 @@
|
|
1
|
-
import { mergeUserJestConfig } from "./modern";
|
2
|
-
describe('modern plugin', function () {
|
3
|
-
test('mergeUserJestConfig support object', function () {
|
4
|
-
var testUtils = {
|
5
|
-
_jestConfig: {
|
6
|
-
a: 1
|
7
|
-
},
|
8
|
-
|
9
|
-
get jestConfig() {
|
10
|
-
return this._jestConfig;
|
11
|
-
},
|
12
|
-
|
13
|
-
testConfig: {
|
14
|
-
jest: {
|
15
|
-
b: 1
|
16
|
-
}
|
17
|
-
},
|
18
|
-
mergeJestConfig: function mergeJestConfig(config) {
|
19
|
-
Object.assign(this._jestConfig, config);
|
20
|
-
}
|
21
|
-
};
|
22
|
-
mergeUserJestConfig(testUtils);
|
23
|
-
expect(testUtils.jestConfig).toEqual({
|
24
|
-
a: 1,
|
25
|
-
b: 1
|
26
|
-
});
|
27
|
-
});
|
28
|
-
test('mergeUserJestConfig support function', function () {
|
29
|
-
var testUtils = {
|
30
|
-
_jestConfig: {
|
31
|
-
a: 1
|
32
|
-
},
|
33
|
-
|
34
|
-
get jestConfig() {
|
35
|
-
return this._jestConfig;
|
36
|
-
},
|
37
|
-
|
38
|
-
testConfig: {
|
39
|
-
jest: function jest(jestConfig) {
|
40
|
-
jestConfig.b = 1;
|
41
|
-
}
|
42
|
-
},
|
43
|
-
mergeJestConfig: function mergeJestConfig(config) {
|
44
|
-
Object.assign(this._jestConfig, config);
|
45
|
-
}
|
46
|
-
};
|
47
|
-
mergeUserJestConfig(testUtils);
|
48
|
-
expect(testUtils.jestConfig).toEqual({
|
49
|
-
a: 1,
|
50
|
-
b: 1
|
51
|
-
});
|
52
|
-
});
|
53
|
-
});
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|