Last active
April 18, 2020 12:48
-
-
Save jeserkin/2e417326418cde2b06bd97dbb79a3ec2 to your computer and use it in GitHub Desktop.
Jest config to support testing in both IDE and CLI
This file contains 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
module.exports = { | |
testMatch: ['**/+(*.)+(spec).+(ts|js)?(x)'], | |
transform: { | |
'^.+\\.(ts|js|html)$': 'ts-jest' | |
}, | |
resolver: '@nrwl/jest/plugins/resolver', | |
moduleFileExtensions: ['ts', 'js', 'html'], | |
collectCoverage: true, | |
coverageReporters: ['html', 'lcov', 'text'], | |
verbose: true, | |
coverageThreshold: { | |
global: { | |
statements: 100, | |
branches: 100, | |
functions: 100, | |
lines: 100 | |
} | |
} | |
}; | |
if (process.env.IDE) { | |
const fs = require('fs'); | |
let path = '<rootDir>'; | |
try { | |
if (fs.existsSync(process.cwd() + '/src/test-setup.ts')) { | |
path = process.cwd(); | |
} | |
} | |
catch (e) { | |
} | |
module.exports.globals = { | |
'ts-jest': { | |
tsConfig: `${path}/tsconfig.spec.json`, | |
stringifyContentPathRegex: '\\.html$', | |
astTransformers: [ | |
'jest-preset-angular/InlineHtmlStripStylesTransformer', | |
], | |
}, | |
}; | |
module.exports.setupFilesAfterEnv = [`${path}/src/test-setup.ts`]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment