I'm trying to debug a jest test but it doesn't seem as though any config is running from launch.json. Only the attach configs work.
This is an example of the configs I am trying to run.
{
"type": "node",
"request": "launch",
"name": "Jest Current File",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"${fileBasenameNoExtension}",
"--config"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js"
}
}
When I attempt to run this config I end up with the following error
Message: "ENOENT: no such file or directory, stat '/home/Projects/PublicTransitGraph/node_modules/jest/bin/package.json'"
Stack:
"Error: ENOENT: no such file or directory, stat '/home/Projects/PublicTransitGraph/node_modules/jest/bin/package.json'
at statSync (fs.js:1016:3)\n at AsyncFunction.module.exports.sync (/home/Projects/PublicTransitGraph/node_modules/pkg-dir/node_modules/locate-path/index.js:57:17)
at runMatcher (/home/Projects/PublicTransitGraph/node_modules/pkg-dir/node_modules/find-up/index.js:54:22)
at AsyncFunction.module.exports.sync (/home/Projects/PublicTransitGraph/node_modules/pkg-dir/node_modules/find-up/index.js:67:21)
at AsyncFunction.module.exports.sync (/home/Projects/PublicTransitGraph/node_modules/pkg-dir/index.js:15:26)
at module.exports (/home/Projects/PublicTransitGraph/node_modules/import-local/index.js:7:27)\n at Object.<anonymous> (/home/Projects/PublicTransitGraph/node_modules/jest/bin/jest.js:11:6)
at Module._compile (internal/modules/cjs/loader.js:1137:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)"
I've changed from workspaceFolder to workspaceRoot but it doesn't seem to do anything.
It seems to be looking for a package.json in the bin folder for the jest module but there isn't any there. I don't know why its even looking there when running it through the command line doesn't give the error.
This is another config that I got directly from jest's website.
But when running this one the path gets appended incorrectly apparently and it gives me no such file or directory error
{
"name": "Debug Jest Tests",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/jest/bin/jest.js",
"--runInBand"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
}
Message: "ENOENT: no such file or directory, stat '/home/Projects/PublicTransitGraph/node_modules/jest/bin/package.json'"
"Error: ENOENT: no such file or directory, stat '/home/Projects/PublicTransitGraph/node_modules/jest/bin/package.json'
at statSync (fs.js:1016:3)
at AsyncFunction.module.exports.sync (/home/Projects/PublicTransitGraph/node_modules/pkg-dir/node_modules/locate-path/index.js:57:17)
at runMatcher (/home/Projects/PublicTransitGraph/node_modules/pkg-dir/node_modules/find-up/index.js:54:22)
at AsyncFunction.module.exports.sync (/home/Projects/PublicTransitGraph/node_modules/pkg-dir/node_modules/find-up/index.js:67:21)
at AsyncFunction.module.exports.sync (/home/Projects/PublicTransitGraph/node_modules/pkg-dir/index.js:15:26)
at module.exports (/home/Projects/PublicTransitGraph/node_modules/import-local/index.js:7:27)
at Object.<anonymous> (/home/Projects/PublicTransitGraph/node_modules/jest/bin/jest.js:11:6)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)"