Created
July 18, 2018 17:04
-
-
Save Kashkovsky/19ae675ac0985163cd0048800f503f3c to your computer and use it in GitHub Desktop.
Debug typescript jest tests in VS Code
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
/** .vscode/launch.json */ | |
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"type": "node", | |
"request": "launch", | |
"name": "Jest Tests", | |
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js", | |
"args": [ | |
"-i" | |
], | |
"preLaunchTask": "ts", | |
"internalConsoleOptions": "openOnSessionStart", | |
"outFiles": [ | |
"${workspaceRoot}/dist/**/*" | |
] | |
} | |
,] | |
} |
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
/** Jest configuration section */ | |
... | |
"jest": { | |
"roots": [ | |
"<rootDir>/dist" | |
], | |
"transform": { | |
"^.+\\.tsx?$": "ts-jest" // install ts-jest to be able to set breakpoints in tsx files | |
}, | |
"testRegex": "(/__tests__/.*|(\\.|/)(spec))\\.js$", | |
"moduleFileExtensions": [ | |
"js" | |
], | |
"snapshotSerializers": [ | |
"enzyme-to-json/serializer" | |
], | |
"setupTestFrameworkScriptFile": "<rootDir>/buildScripts/testSetup.js", | |
"testEnvironment": "<rootDir>/buildScripts/environment.js" | |
} | |
... |
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
/** .vscode/tasks.json */ | |
{ | |
"version": "2.0.0", | |
"tasks": [ | |
{ | |
"label": "ts", | |
"type": "typescript", | |
"tsconfig": "wwwroot/App/reactApp/tsconfig.json", | |
"problemMatcher": [ | |
"$tsc" | |
], | |
"group": { | |
"kind": "build", | |
"isDefault": true | |
} | |
} | |
] | |
} |
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
/** React adapter for Enzyme */ | |
const Enzyme = require("enzyme"); | |
const ReactSixteenAdapter = require("enzyme-adapter-react-16"); | |
Enzyme.configure({ adapter: new ReactSixteenAdapter() }); |
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
Show hidden characters
/** [optional] extends main tsconfig, sets output directory */ | |
{ | |
"extends": "../tsconfig.json", | |
"compilerOptions": { | |
"module": "commonjs", | |
"outDir": "dist" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment