Skip to content

Instantly share code, notes, and snippets.

@ValchanOficial
Created February 10, 2024 19:20
Show Gist options
  • Save ValchanOficial/14b6150cb303add821efc744d2d1a80c to your computer and use it in GitHub Desktop.
Save ValchanOficial/14b6150cb303add821efc744d2d1a80c to your computer and use it in GitHub Desktop.
[Jest] config
package.json
{
"name": "config",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "npx jest --runInBand test/",
"test:dev": "npx jest --runInBand --watchAll test/",
"test:debug": "node --experimental-vm-modules --inspect-brk node_modules/.bin/jest --runInBand --watchAll test/"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"jest": "^29.7.0"
},
"engines": {
"node": "20.x"
}
}
-------------------------------------------------------
.vscode/tasks.json
{
"version": "2.0.0",
"tasks": [{
"label": "run-project-tests",
"type": "shell",
"command": "bash",
"args": [
"-c",
". ~/.nvm/nvm.sh && nvm use v20; PROJECT_DIR=$(dirname ${file}); cd \"${PROJECT_DIR}\"; npm run test:debug"
],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
},
"problemMatcher": []
}]
}
// Let the file tab open
// Ctrl + Shift + B or View > Command Palette > Tasks: Run Build Task
-------------------------------------------------------
.vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Node.js Debug Port",
"request": "attach",
"port": 9229,
"type": "node",
"skipFiles": [
"<node_internals>/**",
"${workspaceFolder}/**/node_modules/**/*.js",
],
"smartStep": true,
"internalConsoleOptions": "openOnFirstSessionStart",
"restart": true
}
]
}
// npm run test:debug
// F5 to start debugging
// Should appear this message: Debugger attached.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment