-
-
Notifications
You must be signed in to change notification settings - Fork 681
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: parallelizing cypress tests to speed up pipeline (#1)
Parallelizing cypress tests to speed up pipeline
- Loading branch information
1 parent
d3cc53c
commit f946577
Showing
5 changed files
with
46 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const NODE_INDEX = Number(process.argv[2] || 1); | ||
const NODE_TOTAL = Number(process.argv[3] || 1); | ||
|
||
const TEST_FOLDER = './cypress/test'; | ||
|
||
console.log(getSpecFiles().join(',')) | ||
|
||
function getSpecFiles() { | ||
const allSpecFiles = traverse(TEST_FOLDER); | ||
const node_index= NODE_INDEX +1; | ||
return allSpecFiles.sort() | ||
.filter((_, index) => (index % NODE_TOTAL) === (node_index - 1)); | ||
|
||
} | ||
|
||
function traverse(dir) { | ||
let files = fs.readdirSync(dir); | ||
files = files.map(file => { | ||
const filePath = path.join(dir, file); | ||
const stats = fs.statSync(filePath); | ||
if (stats.isDirectory()) return traverse(filePath); | ||
else if (stats.isFile())return filePath; | ||
}); | ||
|
||
return files | ||
.reduce((all, folderContents) => all.concat(folderContents), []); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters