Skip to content

Commit

Permalink
fix: file name is not unique enough when running tests in parallel (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
kobenguyent committed Jun 23, 2023
1 parent 06045e1 commit 9c92294
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/helper/Playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const path = require('path');
const fs = require('fs');

const Helper = require('@codeceptjs/helper');
const { v4: uuidv4 } = require('uuid');
const Locator = require('../locator');
const recorder = require('../recorder');
const stringIncludes = require('../assert/include').includes;
Expand Down Expand Up @@ -3111,7 +3112,7 @@ async function refreshContextSession() {

async function saveVideoForPage(page, name) {
if (!page.video()) return null;
const fileName = `${`${global.output_dir}${pathSeparator}videos${pathSeparator}${Date.now()}_${clearString(name)}`.slice(0, 245)}.webm`;
const fileName = `${`${global.output_dir}${pathSeparator}videos${pathSeparator}${uuidv4()}_${clearString(name)}`.slice(0, 245)}.webm`;
page.video().saveAs(fileName).then(() => {
if (!page) return;
page.video().delete().catch(e => {});
Expand All @@ -3122,7 +3123,7 @@ async function saveVideoForPage(page, name) {
async function saveTraceForContext(context, name) {
if (!context) return;
if (!context.tracing) return;
const fileName = `${`${global.output_dir}${pathSeparator}trace${pathSeparator}${Date.now()}_${clearString(name)}`.slice(0, 245)}.zip`;
const fileName = `${`${global.output_dir}${pathSeparator}trace${pathSeparator}${uuidv4()}_${clearString(name)}`.slice(0, 245)}.zip`;
await context.tracing.stop({ path: fileName });
return fileName;
}

0 comments on commit 9c92294

Please sign in to comment.