Skip to content

Commit

Permalink
Fix playwright trace names
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Oct 26, 2021
1 parent 8d82d76 commit 079698a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions test/lib/browsers/playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ let page: Page
let browser: Browser
let context: BrowserContext
let pageLogs: Array<{ source: string; message: string }> = []
let traceStarted = false

const tracePlaywright = process.env.TRACE_PLAYWRIGHT

Expand All @@ -27,11 +26,10 @@ export async function quit() {
}

class Playwright extends BrowserInterface {
private browserName: string
private activeTrace?: string

async setup(browserName: string) {
if (browser) return
this.browserName = browserName
const headless = !!process.env.HEADLESS

if (browserName === 'safari') {
Expand All @@ -49,14 +47,14 @@ class Playwright extends BrowserInterface {
}

async loadPage(url: string) {
if (traceStarted) {
if (this.activeTrace) {
const traceDir = path.join(__dirname, '../../traces')
const traceOutputPath = path.join(
traceDir,
`${path
.relative(path.join(__dirname, '../../'), process.env.TEST_FILE_PATH)
.replace(/\//g, '-')}`,
`playwright-${encodeURIComponent(url)}-${Date.now()}.zip`
`playwright-${this.activeTrace}-${Date.now()}.zip`
)

await fs.remove(traceOutputPath)
Expand Down Expand Up @@ -110,7 +108,7 @@ class Playwright extends BrowserInterface {
screenshots: true,
snapshots: true,
})
traceStarted = true
this.activeTrace = encodeURIComponent(url)
}
await page.goto(url, { waitUntil: 'load' })
}
Expand Down

0 comments on commit 079698a

Please sign in to comment.