Skip to content

Commit

Permalink
wrap in if
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed Nov 8, 2024
1 parent 3e496df commit 89ac883
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions packages/e2e-tests/src/puppeteerEnvironment.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,25 @@ class PuppeteerEnvironment extends JestPuppeteer.TestEnvironment {
event.name === 'test_fn_failure'
? `${state.currentlyRunningTest.parent.name} ${state.currentlyRunningTest.name}`
: 'before or after hook';
const errors = state.currentlyRunningTest?.errors || [];
const eventError = util.inspect(event);

let errorMessages = '';
errorMessages += `========= ${testName} ==========\n\n`;
errorMessages +=
'started:' +
new Date(event.test.startedAt).toLocaleString() +
' ended:' +
new Date().toLocaleString();
errorMessages += '============end==========\n\n';
errors.forEach((error) => {
errorMessages += `${testName}:${error}\n\n`;
});

errorMessages += '=========================\n\n';
errorMessages += eventError;
if (event.test) {
const errors = state.currentlyRunningTest?.errors || [];
const eventError = util.inspect(event);
errorMessages += `========= ${testName} ==========\n\n`;
errorMessages +=
'started:' +
new Date(event.test.startedAt).toLocaleString() +
' ended:' +
new Date().toLocaleString();
errorMessages += '============end==========\n\n';
errors.forEach((error) => {
errorMessages += `${testName}:${error}\n\n`;
});
errorMessages += '=========================\n\n';
errorMessages += eventError;
}

await this.storeArtifacts(testName, errorMessages);
}
Expand Down

0 comments on commit 89ac883

Please sign in to comment.