Skip to content

Commit

Permalink
fix: add jest config in the templates (jaredpalmer#91)
Browse files Browse the repository at this point in the history
since jest v27, the default test env has been changed to 'node'.
this commit configured it to 'jsdom' in react templates.
refs: https://jestjs.io/blog/2021/05/25/jest-27#flipping-defaults
  • Loading branch information
aladdin-add authored Nov 12, 2021
1 parent 61e3a7c commit 711f414
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/templates/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ const basicTemplate: Template = {
singleQuote: true,
trailingComma: 'es5',
},
jest: {
testEnvironment: 'node',
},
},
};

Expand Down
3 changes: 3 additions & 0 deletions src/templates/react-with-storybook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const storybookTemplate: Template = {
storybook: 'start-storybook -p 6006',
'build-storybook': 'build-storybook',
} as PackageJson['scripts'],
jest: {
testEnvironment: 'jsdom',
},
},
};

Expand Down
3 changes: 3 additions & 0 deletions src/templates/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ const reactTemplate: Template = {
...basicTemplate.packageJson.scripts,
test: 'dts test --passWithNoTests',
} as PackageJson['scripts'],
jest: {
testEnvironment: 'jsdom',
},
},
};

Expand Down
1 change: 1 addition & 0 deletions src/templates/template.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ interface Template {
packageJson: PackageJson & {
husky?: any;
prettier?: any;
jest?: any;
};
}

0 comments on commit 711f414

Please sign in to comment.