Describe the bug
Since the last update of VSCode (v1.106.1) debugging tests from the gutter menu fails with Pty Host throwing a -1 exit code error. This worked perfectly, every time prior to the latest VS Code updated to 1.106.0.
I was having the problem with a single test in a test.each configuration. It may occur for individual tests, I don't know, I haven't tested it.
I did manage to get it working briefly by changing my jest.jestCommandLine value from
{
"jest.jestCommandLine": "../../node_modules/.bin/jest --selectProjects=shared --config=../../jest.config.cjs"
}
to
{
"jest.jestCommandLine": "../../node_modules/.bin/jest --selectProjects=shared --config=../../jest.config.cjs",
"jest.debugMode": true,
"terminal.integrated.shellIntegration.enabled": false
}
This fixed the issue for about 3 executions and then it returned and I haven't been able to get it working again.
Reloading the window, or quitting and restarting does not solve the issue.
To Reproduce
Steps to reproduce the behavior:
- Create a Jest test suite
- Run the tests within VS Code. Gutter icon will be populated, either success or failure, it makes no difference.
- Right click on the gutter icon and select "debug test"
Note: A sample repo will help us identify the bug much faster. 🙏
Expected behavior
It should allow me to step through the code
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
- vscode-jest version: 6.4.4
node -v: 18.20.4
npm -v or yarn --version: pnpm v9.9.0
- jest or react-scripts (if you haven’t ejected) version: 29.7.0
- your vscode-jest settings: all as default
- Operating system: MacOS 15.7.1
Prerequisite
- are you able to run jest from the command line? Yes
- where do you run jest CLI from? It's a recursive process within a mono-repo. Jest runs via
pnpm -r. Presumably from within each package folder. It's a pretty typical pnpm mono-repo setup.
- how do you run your tests from the command line? pnpm test which executes (as an example)
jest --selectProjects=server --config=../../jest.config.cjs --coverage
Additional context
This is a mono-repo with various testable projects located under packages. The functionality was working perfectly before VS Code was updated to v1.106.0. I raised a bug with the VS Code team, they rejected it saying it was your problem.
Contents of jest.config.cjs:
const fs = require('fs')
const path = require('path')
const readJsonWithComments = (filename) => {
const filepath = path.resolve(__dirname, filename)
const data = fs
.readFileSync(filepath, 'utf8')
.replace(/^\s*\/\/.*$/gm, '')
.trim()
return JSON.parse(data)
}
const moduleNameMapper = readJsonWithComments('./jest.moduleMapper.json')
const projects = readJsonWithComments('./jest.projects.json')
const baseConfig = {
collectCoverageFrom: ['src/**/*.ts', 'src/**/*.js'],
coverageDirectory: 'coverage',
coveragePathIgnorePatterns: ['src/testAssets/*', 'decs.d.ts', 'dist/*', 'src/pack.ts'],
coverageThreshold: {
global: {
statements: 80,
branches: 80,
functions: 80,
lines: 80
},
'**/*.ts': {
statements: 80,
branches: 80,
functions: 80,
lines: 80
}
},
extensionsToTreatAsEsm: ['.ts', '.tsx', '.jsx'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
moduleNameMapper,
modulePathIgnorePatterns: ['/dist/'],
testEnvironment: 'node',
testRegex: '(/src/.*\\.jest)\\.(ts|js)x?$',
transformIgnorePatterns: ['node_modules'],
preset: 'ts-jest/presets/default-esm',
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
useESM: true,
isolatedModules: true,
astTransformers: {
after: ['<rootDir>/../test-assets/src/tsJestDecoratorFix.cjs']
}
}
]
},
setupFiles: ['<rootDir>/../test-assets/src/setupJest.ts', '<rootDir>/../test-assets/src/setEnvVars.ts'],
setupFilesAfterEnv: ['<rootDir>/../test-assets/src/extendJestExpect.ts'],
roots: ['<rootDir>', '<rootDir>/../test-assets/src']
}
module.exports = {
projects: [
Object.values(projects).map((project) => ({
...baseConfig,
...project,
// ! Deep merge moduleNameMapper
moduleNameMapper: {
...baseConfig.moduleNameMapper,
...(project.moduleNameMapper || {})
}
}))
]
}
Contents of jest.moduleNameMapper.json
// ! This file has auto-generated parts. Do not edit unless you know what you do.
// ! Auto-generated parts: .["^@app/.*"]
{
"^(\\.{1,2}/.*)\\.js$": "$1",
"node:http": "<rootDir>/../test-assets/src/__mocks__/node-http.ts",
"^@app/meteringAdapter(.*).js$": "<rootDir>/../metering-adapter/src/$1",
"^@app/meteringAdapter(?:/([^/.]+))*(?!.js)$": "<rootDir>/../metering-adapter/src/$1/index.ts",
"^@app/meteringContinuous(.*).js$": "<rootDir>/../metering-continuous/src/$1",
"^@app/meteringContinuous(?:/([^/.]+))*(?!.js)$": "<rootDir>/../metering-continuous/src/$1/index.ts",
"^@app/meteringPriceService(.*).js$": "<rootDir>/../metering-price-service/src/$1",
"^@app/meteringPriceService(?:/([^/.]+))*(?!.js)$": "<rootDir>/../metering-price-service/src/$1/index.ts",
"^@app/server(.*).js$": "<rootDir>/../server/src/$1",
"^@app/server(?:/([^/.]+))*(?!.js)$": "<rootDir>/../server/src/$1/index.ts",
"^@app/shared(.*).js$": "<rootDir>/../shared/src/$1",
"^@app/shared(?:/([^/.]+))*(?!.js)$": "<rootDir>/../shared/src/$1/index.ts",
"^@app/testAssets(.*).js$": "<rootDir>/../test-assets/src/$1",
"^@app/testAssets(?:/([^/.]+))*(?!.js)$": "<rootDir>/../test-assets/src/$1/index.ts"
}
Contents of jest.projects.json
// ! This file has auto-generated parts. Do not edit unless you know what you do.
// ! Auto-generated parts: .*
{
"metering-adapter": {
"displayName": "metering-adapter",
"rootDir": "./"
},
"metering-continuous": {
"displayName": "metering-continuous",
"rootDir": "./"
},
"metering-price-service": {
"displayName": "metering-price-service",
"rootDir": "./"
},
"pack": {
"displayName": "pack",
"rootDir": "./"
},
"server": {
"displayName": "server",
"rootDir": "./"
},
"shared": {
"displayName": "shared",
"rootDir": "./"
},
"transaction": {
"displayName": "transaction",
"rootDir": "./"
}
}
The fastest (and the most fun) way to resolve the issue is to submit a pull request yourself. If you are interested, please check out the contribution guide, we look forward to seeing your PR...
Describe the bug
Since the last update of VSCode (v1.106.1) debugging tests from the gutter menu fails with Pty Host throwing a -1 exit code error. This worked perfectly, every time prior to the latest VS Code updated to 1.106.0.
I was having the problem with a single test in a
test.eachconfiguration. It may occur for individual tests, I don't know, I haven't tested it.I did manage to get it working briefly by changing my
jest.jestCommandLinevalue from{ "jest.jestCommandLine": "../../node_modules/.bin/jest --selectProjects=shared --config=../../jest.config.cjs" }to
{ "jest.jestCommandLine": "../../node_modules/.bin/jest --selectProjects=shared --config=../../jest.config.cjs", "jest.debugMode": true, "terminal.integrated.shellIntegration.enabled": false }This fixed the issue for about 3 executions and then it returned and I haven't been able to get it working again.
Reloading the window, or quitting and restarting does not solve the issue.
To Reproduce
Steps to reproduce the behavior:
Note: A sample repo will help us identify the bug much faster. 🙏
Expected behavior
It should allow me to step through the code
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
node -v: 18.20.4npm -voryarn --version: pnpm v9.9.0Prerequisite
pnpm -r. Presumably from within each package folder. It's a pretty typical pnpm mono-repo setup.jest --selectProjects=server --config=../../jest.config.cjs --coverageAdditional context
This is a mono-repo with various testable projects located under
packages. The functionality was working perfectly before VS Code was updated to v1.106.0. I raised a bug with the VS Code team, they rejected it saying it was your problem.Contents of
jest.config.cjs:Contents of jest.moduleNameMapper.json
Contents of jest.projects.json
The fastest (and the most fun) way to resolve the issue is to submit a pull request yourself. If you are interested, please check out the contribution guide, we look forward to seeing your PR...