Skip to content

Instantly share code, notes, and snippets.

@AwesomeObserver
Last active August 6, 2020 14:49
Show Gist options
  • Save AwesomeObserver/03bcbbc4f4ef6c3ccd8e1f774e375ff9 to your computer and use it in GitHub Desktop.
Save AwesomeObserver/03bcbbc4f4ef6c3ccd8e1f774e375ff9 to your computer and use it in GitHub Desktop.
ng jest
{
"test": {
"builder": "@angular-builders/jest:run",
"options": {
"coverage": true,
"no-cache": true
}
}
}
@angular-builders/jest
@types/jest
jest
jest-localstorage-mock
module.exports = {
"collectCoverageFrom": [
"src/**/*.{js,ts}",
"!src/public-api.ts",
"!src/**/*.spec.{js,ts}",
"!src/**/*.d.ts"
],
"coverageDirectory": "<rootDir>/test-results/coverage",
"coverageReporters": [
"lcovonly",
"json",
"html",
"cobertura",
"text",
"text-summary"
],
"reporters": [
"default"
],
"globals": {
"ts-jest": {
"tsConfig": "<rootDir>/src/tsconfig.spec.json",
"stringifyContentPathRegex": "\\.html$",
"astTransformers": [
'jest-preset-angular/build/InlineFilesTransformer',
'jest-preset-angular/build/StripStylesTransformer'
],
"isolatedModules": true
}
},
"moduleFileExtensions": [
"js",
"ts",
"html"
],
"moduleDirectories": [
"node_modules",
"src"
],
"setupFilesAfterEnv": [
"<rootDir>/setupJest.ts"
],
"testMatch": [
"<rootDir>/src/**/+(*.)+(spec).+(ts|js)"
],
"transform": {
"^.+\\.(ts|js|html)$": "ts-jest"
},
"transformIgnorePatterns": [
"node_modules/(?!(rxjs-compat))"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
"\\.(css)$": "<rootDir>/__mocks__/styleMock.js",
}
};
import 'jest-preset-angular';
import 'jest-localstorage-mock';
window.requestAnimationFrame = fn => {
fn(16);
return 16;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment