Skip to content

Commit c2b56ca

Browse files
committed
refactor(cli): use new preset util functions to initialize test config
1 parent f9cc3c0 commit c2b56ca

File tree

8 files changed

+373
-280
lines changed

8 files changed

+373
-280
lines changed

package-lock.json

+139
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
"@jest/types": "^29.6.3",
100100
"@types/babel__core": "7.20.5",
101101
"@types/cross-spawn": "latest",
102+
"@types/ejs": "^3.1.5",
102103
"@types/fs-extra": "latest",
103104
"@types/js-yaml": "latest",
104105
"@types/lodash.camelcase": "4.3.9",
@@ -115,6 +116,7 @@
115116
"babel-jest": "^29.7.0",
116117
"conventional-changelog-cli": "^5.0.0",
117118
"cross-spawn": "latest",
119+
"ejs": "^3.1.10",
118120
"esbuild": "~0.21.5",
119121
"eslint": "^8.57.0",
120122
"eslint-config-prettier": "^9.1.0",

src/cli/__snapshots__/cli.spec.ts.snap

+114
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,119 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`config init should create a jest config file with cli options for config type default 1`] = `
4+
"/** @type {import('ts-jest').JestConfigWithTsJest} **/
5+
module.exports = {
6+
testEnvironment: "node",
7+
transform: {
8+
"^.+.tsx?$": ["ts-jest",{}],
9+
},
10+
};"
11+
`;
12+
13+
exports[`config init should create a jest config file with cli options for config type default and type "module" package.json 1`] = `
14+
"/** @type {import('ts-jest').JestConfigWithTsJest} **/
15+
export default {
16+
testEnvironment: "node",
17+
transform: {
18+
"^.+.tsx?$": ["ts-jest",{}],
19+
},
20+
};"
21+
`;
22+
23+
exports[`config init should create a jest config file with cli options for config type js-with-babel-full-options 1`] = `
24+
"/** @type {import('ts-jest').JestConfigWithTsJest} **/
25+
module.exports = {
26+
testEnvironment: "jsdom",
27+
transform: {
28+
"^.+.jsx?$": ["babel-jest",{}],
29+
},
30+
};"
31+
`;
32+
33+
exports[`config init should create a jest config file with cli options for config type js-with-babel-full-options and type "module" package.json 1`] = `
34+
"/** @type {import('ts-jest').JestConfigWithTsJest} **/
35+
export default {
36+
testEnvironment: "jsdom",
37+
transform: {
38+
"^.+.jsx?$": ["babel-jest",{}],
39+
},
40+
};"
41+
`;
42+
43+
exports[`config init should create a jest config file with cli options for config type js-with-ts-full-options 1`] = `
44+
"/** @type {import('ts-jest').JestConfigWithTsJest} **/
45+
module.exports = {
46+
testEnvironment: "jsdom",
47+
transform: {
48+
"^.+.[tj]sx?$": ["ts-jest",{tsconfig:"tsconfig.test.json"}],
49+
},
50+
};"
51+
`;
52+
53+
exports[`config init should create a jest config file with cli options for config type js-with-ts-full-options and type "module" package.json 1`] = `
54+
"/** @type {import('ts-jest').JestConfigWithTsJest} **/
55+
export default {
56+
testEnvironment: "jsdom",
57+
transform: {
58+
"^.+.[tj]sx?$": ["ts-jest",{tsconfig:"tsconfig.test.json"}],
59+
},
60+
};"
61+
`;
62+
63+
exports[`config init should update package.json for config type default when user defines jest config via package.json 1`] = `
64+
"{
65+
"name": "mock",
66+
"version": "0.0.0-mock.0",
67+
"jest": {
68+
"transform": {
69+
"^.+.tsx?$": [
70+
"ts-jest",
71+
{}
72+
]
73+
}
74+
}
75+
}"
76+
`;
77+
78+
exports[`config init should update package.json for config type js-with-babel-full-options when user defines jest config via package.json 1`] = `
79+
"{
80+
"name": "mock",
81+
"version": "0.0.0-mock.0",
82+
"jest": {
83+
"transform": {
84+
"^.+.jsx?$": [
85+
"babel-jest",
86+
{}
87+
],
88+
"^.+.tsx?$": [
89+
"ts-jest",
90+
{
91+
"tsconfig": "tsconfig.test.json",
92+
"babelConfig": true
93+
}
94+
]
95+
}
96+
}
97+
}"
98+
`;
99+
100+
exports[`config init should update package.json for config type js-with-ts-full-options when user defines jest config via package.json 1`] = `
101+
"{
102+
"name": "mock",
103+
"version": "0.0.0-mock.0",
104+
"jest": {
105+
"transform": {
106+
"^.+.[tj]sx?$": [
107+
"ts-jest",
108+
{
109+
"tsconfig": "tsconfig.test.json"
110+
}
111+
]
112+
}
113+
}
114+
}"
115+
`;
116+
3117
exports[`config migrate should migrate globals ts-jest config to transformer config 1`] = `
4118
""jest": {
5119
"transform": {

0 commit comments

Comments
 (0)