Skip to content

Commit

Permalink
resolve overlapping testnames issue (#3539)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlaaSayed794 authored and gravityvi committed Apr 6, 2023
1 parent 5557e5a commit a647ee7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/utils/index.js
Expand Up @@ -261,7 +261,8 @@ class Utils {
}
}
}

parentFolder = this.isFileNameValid(parentFolder) ? '' : parentFolder;

return path.join(parentFolder, diffInFolder, moduleName);
}

Expand Down
22 changes: 22 additions & 0 deletions test/src/utils/testUtils.js
Expand Up @@ -206,6 +206,28 @@ describe('test Utils', function() {
console = oldConsole;
});

it('test getModuleKey', function() {
const srcFolderPath = path.join(__dirname, '../../sampletests/before-after');
const {statSync, readdirSync} = require('fs');
const getSrcTestsPaths = (testPath)=>{
let fullPaths = [];
readdirSync(testPath).forEach(file=>{
if (statSync(path.join(testPath, file)).isDirectory()){
fullPaths = [...fullPaths, ...getSrcTestsPaths(path.join(testPath, file))];
} else {
fullPaths.push(path.join(testPath, file));
}
});

return fullPaths;
};
const currentTestPath = path.join(srcFolderPath, 'sampleSingleTest.js');
const testFiles = getSrcTestsPaths(srcFolderPath);
const fullPaths = testFiles.map(file=>({env: 'default', module: file}));
assert.equal(Utils.getModuleKey(currentTestPath, testFiles, fullPaths), 'sampleSingleTest.js');
assert.equal(Utils.getModuleKey(currentTestPath, ['test/sampletests/simple', 'test/sampletests/before-after'], fullPaths), path.join('before-after', 'sampleSingleTest.js'));
});


describe('test findTSConfigFile', function () {
const {constants, rmdirSync} = require('fs');
Expand Down

0 comments on commit a647ee7

Please sign in to comment.