Last active
July 5, 2022 18:53
-
-
Save andrewconnell/2d8c0173df236591cd5d5cf6f2d449cd to your computer and use it in GitHub Desktop.
Jest configuration (with code coverage) - SEE COMMENT IN FRIST LINE FOR IMPORTANT VERSION DETAILS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for SPFx <= v1.14 projects & TypeScript <= v3.9 | |
{ | |
"collectCoverage": true, | |
"coverageDirectory": "<rootDir>/../temp/test", | |
"coverageReporters": [ | |
"json", | |
"lcov", | |
"text-summary" | |
], | |
"coverageThreshold": { | |
"global": { | |
"branches": 50, | |
"functions": 90, | |
"lines": 100, | |
"statements": 100 | |
} | |
}, | |
"globals": { | |
"ts-jest": { | |
"diagnostics": { | |
"ignoreCodes": "TS151001" | |
} | |
} | |
}, | |
"moduleFileExtensions": [ | |
"ts", | |
"tsx", | |
"js", | |
"json" | |
], | |
"moduleNameMapper": { | |
"\\.(css|scss)$": "identity-obj-proxy", | |
"^resx-strings/en-us.json": "<rootDir>/../node_modules/@microsoft/sp-core-library/lib/resx-strings/en-us.json" | |
}, | |
"reporters": [ | |
"default", | |
[ | |
"jest-junit", | |
{ | |
"output": "./temp/test/junit.xml" | |
} | |
] | |
], | |
"rootDir": "../src", | |
"testMatch": [ | |
"**/src/**/*.spec.+(ts|tsx|js)" | |
], | |
"testURL": "http://localhost", | |
"transform": { | |
"^.+\\.(ts|tsx)$": "ts-jest" | |
}, | |
"verbose": true | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for SPFx >= v1.15 projects & TypeScript >= v4.5 | |
{ | |
"collectCoverage": true, | |
"coverageDirectory": "<rootDir>/../temp/test", | |
"collectCoverageFrom": [ | |
"<rootDir>/**/*.{ts,tsx}", | |
"!<rootDir>/**/*.scss.*", | |
"!<rootDir>/**/webparts/**/*.ts", | |
"!<rootDir>/loc/**/*.*" | |
], | |
"coverageReporters": [ | |
"json", | |
"lcov", | |
"text-summary" | |
], | |
"coverageThreshold": { | |
"global": { | |
"branches": 50, | |
"functions": 90, | |
"lines": 100, | |
"statements": 100 | |
} | |
}, | |
"globals": { | |
"ts-jest": { | |
"diagnostics": { | |
"ignoreCodes": "TS151001" | |
} | |
} | |
}, | |
"moduleFileExtensions": [ | |
"ts", | |
"tsx", | |
"js", | |
"json" | |
], | |
"moduleNameMapper": { | |
"\\.(css|scss)$": "identity-obj-proxy", | |
"^resx-strings/en-us.json": "<rootDir>/../node_modules/@microsoft/sp-core-library/lib/resx-strings/en-us.json" | |
}, | |
"reporters": [ | |
"default", | |
[ | |
"jest-junit", | |
{ | |
"outputDirectory": "temp/test", | |
"outputName": "junit.xml" | |
} | |
] | |
], | |
"rootDir": "../src", | |
"testMatch": [ | |
"**/src/**/*.spec.+(ts|tsx|js)" | |
], | |
"testEnvironmentOptions": { | |
"url": "http://www.something.com/test.html" | |
}, | |
"transform": { | |
"^.+\\.(ts|tsx)$": "ts-jest" | |
}, | |
"verbose": true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment