Skip to content

Commit 5c87294

Browse files
committed
test: fix babel test transpilation
1 parent 41b6114 commit 5c87294

File tree

3 files changed

+28
-18
lines changed

3 files changed

+28
-18
lines changed

.babelrc.js

+22-12
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
11
const sharedPresets = [];
2-
const shared = {
3-
4-
}
2+
const shared = {};
53

64
module.exports = {
75
env: {
86
esmUnbundled: shared,
97
esmBundled: {
108
...shared,
11-
presets: [['@babel/env', {
12-
targets: "> 0.25%, not dead"
13-
}], ...sharedPresets],
9+
presets: [
10+
[
11+
'@babel/env',
12+
{
13+
targets: '> 0.25%, not dead'
14+
}
15+
],
16+
...sharedPresets
17+
]
1418
},
1519
cjs: {
1620
...shared,
17-
presets: [['@babel/env', {
18-
modules: 'commonjs'
19-
}], ...sharedPresets],
21+
presets: [
22+
[
23+
'@babel/env',
24+
{
25+
modules: 'commonjs'
26+
}
27+
],
28+
...sharedPresets
29+
]
2030
},
2131
test: {
22-
presets: ['@babel/env', ...sharedPresets]
23-
},
32+
presets: [['@babel/env', { targets: { node: 'current' } }], ...sharedPresets]
33+
}
2434
}
25-
}
35+
};

jest.config.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ module.exports = {
2525

2626
// The directory where Jest should output its coverage files
2727
coverageDirectory: 'coverage',
28-
2928
// An array of regexp pattern strings used to skip coverage collection
3029
// coveragePathIgnorePatterns: [
3130
// "/node_modules/"
@@ -124,7 +123,7 @@ module.exports = {
124123
// snapshotSerializers: [],
125124

126125
// The test environment that will be used for testing
127-
testEnvironment: 'jsdom'
126+
testEnvironment: 'jsdom',
128127

129128
// Options that will be passed to the testEnvironment
130129
// testEnvironmentOptions: {},
@@ -159,8 +158,9 @@ module.exports = {
159158
// timers: "real",
160159

161160
// A map from regular expressions to paths to transformers
162-
// transform: null,
163-
161+
transform: {
162+
'\\.[jt]sx?$': 'babel-jest'
163+
}
164164
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
165165
// transformIgnorePatterns: [
166166
// "/node_modules/"

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"prebuild": "yarn run lint",
1818
"prepare": "husky install",
1919
"dev": "rollup -c -w --config rollup.dev.js",
20-
"test-unit": "jest",
21-
"test-dev": "jest --watch",
20+
"test-unit": "BABEL_ENV=test jest",
21+
"test-dev": "BABEL_ENV=test jest --watch",
2222
"lint": "yarn run lint-code && yarn run lint-size",
2323
"lint-code": "yarn eslint src test",
2424
"lint-size": "yarn size-limit",

0 commit comments

Comments
 (0)