mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 01:39:44 +01:00
e2e multiple reports (#17715)
* multiple reports * fix run all * clean up report
This commit is contained in:
parent
18a1b80524
commit
c00f74e95e
@ -1,3 +1,4 @@
|
||||
const fs = require('fs');
|
||||
const spawn = require('cross-spawn');
|
||||
|
||||
/**
|
||||
@ -87,17 +88,20 @@ async function runCommand(command, args) {
|
||||
*
|
||||
* @param {string} command - The command to run
|
||||
* @param {Array<string>} [args] - The arguments to pass to the command
|
||||
* @param {string} output - The output file to write to
|
||||
*/
|
||||
async function runInShell(command, args) {
|
||||
async function runInShell(command, args, output) {
|
||||
let errorSignal;
|
||||
let errorCode;
|
||||
const internalError = new Error('Internal');
|
||||
try {
|
||||
await new Promise((resolve, reject) => {
|
||||
const childProcess = spawn(command, args, {
|
||||
encoding: 'utf8',
|
||||
stdio: 'inherit',
|
||||
});
|
||||
const childProcess = spawn(command, args);
|
||||
childProcess.stdout.setEncoding('utf8');
|
||||
childProcess.stdout.pipe(process.stdout);
|
||||
if (output) {
|
||||
childProcess.stdout.pipe(fs.createWriteStream(output));
|
||||
}
|
||||
|
||||
childProcess.once('exit', (code, signal) => {
|
||||
if (code === 0) {
|
||||
|
@ -38,7 +38,7 @@
|
||||
"test:e2e:firefox:snaps": "SELENIUM_BROWSER=firefox node test/e2e/run-all.js --snaps",
|
||||
"test:e2e:firefox:nft": "SELENIUM_BROWSER=firefox node test/e2e/run-all.js --nft",
|
||||
"test:e2e:single": "node test/e2e/run-e2e-test.js",
|
||||
"test:e2e:report": "jrm ./test/test-results/e2e.xml \"./test/test-results/e2e/*.xml\"",
|
||||
"test:e2e:report": "node ./test/e2e/e2e-process-report.js && jrm ./test/test-results/e2e.xml \"./test/test-results/e2e/*.xml\"",
|
||||
"test:coverage:mocha": "node ./test/run-unit-tests.js --mocha --coverage",
|
||||
"test:coverage:jest": "node ./test/run-unit-tests.js --jestGlobal --coverage",
|
||||
"test:coverage:jest:dev": "node ./test/run-unit-tests.js --jestDev --coverage",
|
||||
|
10
test/e2e/e2e-process-report.js
Normal file
10
test/e2e/e2e-process-report.js
Normal file
@ -0,0 +1,10 @@
|
||||
const fs = require('fs');
|
||||
|
||||
const dir = 'test/test-results/e2e';
|
||||
|
||||
fs.readdirSync(dir).forEach((file) => {
|
||||
const currentFile = `${dir}/${file}`;
|
||||
let data = fs.readFileSync(currentFile, { encoding: 'utf8', flag: 'r' });
|
||||
data = data.substring(data.indexOf('<testsuite'));
|
||||
fs.writeFileSync(currentFile, data);
|
||||
});
|
@ -108,6 +108,8 @@ async function main() {
|
||||
const currentChunk = chunks[currentChunkIndex];
|
||||
|
||||
for (const testPath of currentChunk) {
|
||||
const dir = 'test/test-results/e2e';
|
||||
fs.mkdir(dir, { recursive: true });
|
||||
await runInShell('node', [...args, testPath]);
|
||||
}
|
||||
}
|
||||
|
@ -93,17 +93,22 @@ async function main() {
|
||||
|
||||
const configFile = path.join(__dirname, '.mocharc.js');
|
||||
|
||||
const dir = 'test/test-results/e2e';
|
||||
fs.mkdir(dir, { recursive: true });
|
||||
|
||||
await retry({ retries }, async () => {
|
||||
await runInShell('yarn', [
|
||||
'mocha',
|
||||
`--config=${configFile}`,
|
||||
`--timeout=${testTimeoutInMilliseconds}`,
|
||||
'--reporter=xunit',
|
||||
'--reporter-option',
|
||||
`output=test/test-results/e2e/${testFileName}.xml`,
|
||||
e2eTestPath,
|
||||
exit,
|
||||
]);
|
||||
await runInShell(
|
||||
'yarn',
|
||||
[
|
||||
'mocha',
|
||||
`--config=${configFile}`,
|
||||
`--timeout=${testTimeoutInMilliseconds}`,
|
||||
'--reporter=xunit',
|
||||
e2eTestPath,
|
||||
exit,
|
||||
],
|
||||
`${dir}/${testFileName}.xml`,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user