You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I move the creation of the jasmine instance (Lines 115+116) inside the forEach, i.e. a new one for each file, the test cases only appear for the correct file.
The test runner needs to add all the files to jasmine in one call instead of a call for each file.
For those that need a workaround, replace the following two functions in the VS Jasmine test runner file (e.g.: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\Extensions\Microsoft\NodeJsTools\TestAdapter\TestFrameworks\Jasmine\jasmine.js).
async function find_tests(testFileList, discoverResultFile, projectFolder) {
var Jasmine = detectJasmine(projectFolder);
if (!Jasmine) {
return;
}
var jasmineInstance = initializeJasmine(Jasmine, projectFolder);
setSpecFilter(jasmineInstance, _ => false);
var testList = [];
try {
jasmineInstance.specDir = "";
jasmineInstance.specFiles = [];
// In Jasmine 4.0+ addSpecFiles has been deprecated in favor of addMatchingSpecFiles
(jasmineInstance.addMatchingSpecFiles || jasmineInstance.addSpecFiles).apply(jasmineInstance, [testFileList.split(";")]);
var p = jasmineInstance.loadSpecs();
if (p instanceof Promise) {
await p;
}
var topSuite = jasmineInstance.env.topSuite();
// In Jasmine 4.0+ the Suite object is not top level anymore and is instead in the suite_ property
if (topSuite && topSuite.suite_) {
topSuite = topSuite.suite_;
}
enumerateSpecs(topSuite, testList);
}
catch (ex) {
//we would like continue discover other files, so swallow, log and continue;
console.error("Test discovery error:", ex);
}
var fd = fs.openSync(discoverResultFile, 'w');
fs.writeSync(fd, JSON.stringify(testList));
fs.closeSync(fd);
}
function enumerateSpecs(suite, testList) {
suite.children.forEach((child) => {
if (child instanceof jasmine.Suite) {
enumerateSpecs(child, testList);
} else {
testList.push({
name: child.description,
suite: suite.description === "Jasmine__TopLevel__Suite" ? null : suite.getFullName(),
filepath: child.filename.replace(/^file:\/\/\//i, ''),
line: 0,
column: 0
});
}
});
}
Expected Behavior
Test cases are just listed under the file they exist in
Actual Behavior
Test cases are also listed under all subsequent files
I think the issue might be some form of caching in here.
nodejstools/Nodejs/Product/TestAdapter/TestFrameworks/Jasmine/jasmine.js
Lines 115 to 126 in 587d045
If I move the creation of the jasmine instance (Lines 115+116) inside the forEach, i.e. a new one for each file, the test cases only appear for the correct file.
Steps to Reproduce
The text was updated successfully, but these errors were encountered: