Skip to content

Commit

Permalink
refactor(cli): use new preset util functions to initialize test config
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnpnl committed Jun 27, 2024
1 parent f9cc3c0 commit c2b56ca
Show file tree
Hide file tree
Showing 8 changed files with 373 additions and 280 deletions.
139 changes: 139 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"@jest/types": "^29.6.3",
"@types/babel__core": "7.20.5",
"@types/cross-spawn": "latest",
"@types/ejs": "^3.1.5",
"@types/fs-extra": "latest",
"@types/js-yaml": "latest",
"@types/lodash.camelcase": "4.3.9",
Expand All @@ -115,6 +116,7 @@
"babel-jest": "^29.7.0",
"conventional-changelog-cli": "^5.0.0",
"cross-spawn": "latest",
"ejs": "^3.1.10",
"esbuild": "~0.21.5",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
Expand Down
114 changes: 114 additions & 0 deletions src/cli/__snapshots__/cli.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,119 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`config init should create a jest config file with cli options for config type default 1`] = `
"/** @type {import('ts-jest').JestConfigWithTsJest} **/
module.exports = {
testEnvironment: "node",
transform: {
"^.+.tsx?$": ["ts-jest",{}],
},
};"
`;

exports[`config init should create a jest config file with cli options for config type default and type "module" package.json 1`] = `
"/** @type {import('ts-jest').JestConfigWithTsJest} **/
export default {
testEnvironment: "node",
transform: {
"^.+.tsx?$": ["ts-jest",{}],
},
};"
`;

exports[`config init should create a jest config file with cli options for config type js-with-babel-full-options 1`] = `
"/** @type {import('ts-jest').JestConfigWithTsJest} **/
module.exports = {
testEnvironment: "jsdom",
transform: {
"^.+.jsx?$": ["babel-jest",{}],
},
};"
`;

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`] = `
"/** @type {import('ts-jest').JestConfigWithTsJest} **/
export default {
testEnvironment: "jsdom",
transform: {
"^.+.jsx?$": ["babel-jest",{}],
},
};"
`;

exports[`config init should create a jest config file with cli options for config type js-with-ts-full-options 1`] = `
"/** @type {import('ts-jest').JestConfigWithTsJest} **/
module.exports = {
testEnvironment: "jsdom",
transform: {
"^.+.[tj]sx?$": ["ts-jest",{tsconfig:"tsconfig.test.json"}],
},
};"
`;

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`] = `
"/** @type {import('ts-jest').JestConfigWithTsJest} **/
export default {
testEnvironment: "jsdom",
transform: {
"^.+.[tj]sx?$": ["ts-jest",{tsconfig:"tsconfig.test.json"}],
},
};"
`;

exports[`config init should update package.json for config type default when user defines jest config via package.json 1`] = `
"{
"name": "mock",
"version": "0.0.0-mock.0",
"jest": {
"transform": {
"^.+.tsx?$": [
"ts-jest",
{}
]
}
}
}"
`;

exports[`config init should update package.json for config type js-with-babel-full-options when user defines jest config via package.json 1`] = `
"{
"name": "mock",
"version": "0.0.0-mock.0",
"jest": {
"transform": {
"^.+.jsx?$": [
"babel-jest",
{}
],
"^.+.tsx?$": [
"ts-jest",
{
"tsconfig": "tsconfig.test.json",
"babelConfig": true
}
]
}
}
}"
`;

exports[`config init should update package.json for config type js-with-ts-full-options when user defines jest config via package.json 1`] = `
"{
"name": "mock",
"version": "0.0.0-mock.0",
"jest": {
"transform": {
"^.+.[tj]sx?$": [
"ts-jest",
{
"tsconfig": "tsconfig.test.json"
}
]
}
}
}"
`;

exports[`config migrate should migrate globals ts-jest config to transformer config 1`] = `
""jest": {
"transform": {
Expand Down
Loading

0 comments on commit c2b56ca

Please sign in to comment.