Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Commit 309a0ce

Browse files
Merge pull request #177 from microsoft/users/t-xunguy/react-jest
Set up Unit Test for typescript/react
2 parents 5fe49a1 + 04a96d3 commit 309a0ce

File tree

5 files changed

+7130
-1395
lines changed

5 files changed

+7130
-1395
lines changed

jest.config.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module.exports = {
2+
// The root of your source code, typically /src
3+
// `<rootDir>` is a token Jest substitutes
4+
roots: ["<rootDir>/src"],
5+
6+
// Jest transformations -- this adds support for TypeScript
7+
// using ts-jest
8+
transform: {
9+
'^.+\\.tsx?$': 'ts-jest',
10+
".+\\.(css|styl|less|sass|scss)$": "jest-transform-css"
11+
},
12+
13+
// Runs special logic, such as cleaning up components
14+
// when using React Testing Library and adds special
15+
// extended assertions to Jest
16+
setupFilesAfterEnv: [
17+
"@testing-library/jest-dom/extend-expect"
18+
],
19+
20+
// Test spec file resolution pattern
21+
// Matches parent folder `__tests__` and filename
22+
// should contain `test` or `spec`.
23+
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
24+
25+
// Module file extensions for importing
26+
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
27+
28+
};

0 commit comments

Comments
 (0)