Created
July 2, 2019 05:05
-
-
Save thlinhit/f30cc041544177b386e22c99aac68207 to your computer and use it in GitHub Desktop.
Jest test + debug
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
import 'jest-preset-angular'; | |
window.matchMedia = | |
window.matchMedia || | |
(() => { | |
return ({ | |
matches: false, | |
addListener: () => {}, | |
removeListener: () => {} | |
} as unknown) as MediaQueryList; | |
}); | |
window.fetch = require('node-fetch'); |
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
module.exports = { | |
name: "pdv-isp-b2e-rwc", | |
preset: "jest-preset-angular", | |
snapshotSerializers: [ | |
"jest-preset-angular/AngularSnapshotSerializer.js", | |
"jest-preset-angular/HTMLCommentSerializer.js" | |
], | |
setupFilesAfterEnv: [ | |
"<rootDir>/jest-setup.ts", | |
], | |
transform: { | |
'^.+\\.(ts|html)$': 'ts-jest' | |
}, | |
resolver: '@nrwl/builders/plugins/jest/resolver', | |
moduleFileExtensions: ['ts', 'js', 'html', 'json'], | |
moduleNameMapper: { | |
"\\.(css|less|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|ico)$": | |
"<rootDir>/jest-file-mocks.js", // mock url-loader paths so ux-framework doesn"t break tests | |
"^url-loader!../assets/favicons/(.*)$": "<rootDir>/jest-file-mocks.js", | |
}, | |
collectCoverage: false, // must be false, otherwise local debug does not work. Must be true in angular.json! | |
coverageDirectory: "../../coverage/pdv-isp-b2e-rwc", | |
coverageReporters: ["html", "teamcity", "text-summary"], | |
coveragePathIgnorePatterns: ['/node_modules/', 'testhelper.ts', '.*mock.*.ts$'], | |
testRegex: [".*spec.ts$"], | |
testResultsProcessor: "jest-teamcity-reporter", | |
globals: { | |
"ts-jest": { | |
"tsConfig": "<rootDir>/tsconfig.spec.json" | |
} | |
} | |
}; |
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
{ | |
// Use IntelliSense to learn about possible attributes. | |
// Hover to view descriptions of existing attributes. | |
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"type": "node", | |
"request": "launch", | |
"name": "Jest Test", | |
"program": "${workspaceFolder}/node_modules/jest/bin/jest", | |
"args": ["--runInBand", "--config=${workspaceFolder}/projects/pdv-isp-b2e-rwc/jest.config.js"], | |
"console": "integratedTerminal", | |
"internalConsoleOptions": "neverOpen" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment