Skip to content

Commit

Permalink
Merge f25a288 into b92c6f8
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianisk committed Jun 27, 2023
2 parents b92c6f8 + f25a288 commit 24e13dc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
18 changes: 4 additions & 14 deletions src/DebugConfigurationProvider.ts
Expand Up @@ -109,20 +109,10 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
if (typeof arg !== 'string') {
return arg;
}
switch (true) {
case testFileRegex.test(arg): {
return arg.replace(testFileRegex, toFilePath(this.fileNameToRun));
}
case testFilePatternRegex.test(arg): {
return arg.replace(testFilePatternRegex, escapeRegExp(this.fileNameToRun));
}
case testNamePatternRegex.test(arg): {
return arg.replace(testNamePatternRegex, this.testToRun);
}

default:
return arg;
}
return arg
.replace(testFileRegex, toFilePath(this.fileNameToRun))
.replace(testFilePatternRegex, escapeRegExp(this.fileNameToRun))
.replace(testNamePatternRegex, this.testToRun);
});
debugConfiguration.args = args;

Expand Down
20 changes: 20 additions & 0 deletions tests/DebugConfigurationProvider.test.ts
Expand Up @@ -128,6 +128,26 @@ describe('DebugConfigurationProvider', () => {
expect(configuration).toBeDefined();
expect(configuration.args).toEqual(expected);
});
it('will translate multiple variables in a single arg', () => {
(toFilePath as unknown as jest.Mock<{}>).mockReturnValueOnce(fileName);
(escapeRegExp as unknown as jest.Mock<{}>).mockReturnValueOnce(fileNamePattern);

let configuration: any = {
name: 'vscode-jest-tests.v2',
args: ['--testNamePattern "${jest.testNamePattern}" --runTestsByPath "${jest.testFile}"'],
};

const sut = new DebugConfigurationProvider();
const ws = makeWorkspaceFolder('whatever');
sut.prepareTestRun(fileName, testName, ws);

configuration = sut.resolveDebugConfiguration(undefined, configuration);

expect(configuration).toBeDefined();
expect(configuration.args).toEqual([
`--testNamePattern "${testName}" --runTestsByPath "${fileName}"`,
]);
});
});
describe('can generate debug config with jestCommandLine and rootPath', () => {
const canRunTest = (isWin32: boolean) =>
Expand Down

0 comments on commit 24e13dc

Please sign in to comment.