Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const testResultFileName = `test-result-${testRunId}.json`;
const outputFilePath = path.join(tempFolder, testResultFileName);
// Specify --runTestsByPath if running test on individual files
let runTestsByPathArgs: string[];
if (kind === TestInfoKind.TEST_FILE || kind === TestInfoKind.TEST_CASE) {
const workspaceFolderFsPath = workspaceFolder.uri.fsPath;
runTestsByPathArgs = [
'--runTestsByPath',
normalizeRunTestsByPath(workspaceFolderFsPath, testFsPath)
];
} else {
runTestsByPathArgs = [];
}
const testNamePatternArgs = testName
? ['--testNamePattern', `"${escapeStrForRegex(testName)}"`]
: [];
let runModeArgs: string[];
if (testRunType === TestRunType.WATCH) {
runModeArgs = ['--watch'];
} else {
runModeArgs = [];
}
const args = [
...runModeArgs,
'--json',
'--outputFile',
outputFilePath,
'--testLocationInResults',
...runTestsByPathArgs,
...testNamePatternArgs
export function extractPositionFromFailureMessage(
testFsPath: string,
failureMessage: string
) {
try {
const locationMatcher = new RegExp(
escapeStrForRegex(testFsPath) + '\\:(\\d+)\\:(\\d+)',
'i'
);
const matchResult = failureMessage.match(locationMatcher);
if (matchResult) {
const lineString = matchResult[1];
const columnString = matchResult[2];
const line = parseInt(lineString, 10);
const column = parseInt(columnString, 10);
if (isNaN(line) || isNaN(column)) {
return undefined;
}
return new vscode.Position(line - 1, column - 1);
}
return undefined;
} catch (error) {
return undefined;
p.run(value => {
updateConfigAndRun({
mode: 'watch',
testNamePattern: escapeStrForRegex(removeTrimmingDots(value)),
});
res();
}, rej);
});