Skip to content

Commit

Permalink
Fix screenshot overwriting
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Brody committed Sep 17, 2024
1 parent 5ef2e84 commit ba025de
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions react/test/test_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,11 @@ function test_file_name(): string {
throw new Error(`Test file not found in args: ${process.argv}`)
}

let screenshot_number = 0

function screenshot_path(t: TestController): string {
let number = 0
const resultPath = (): string => `${test_file_name()}/${t.browser.name}/${t.test.name}-${number}.png`
while (fs.existsSync(resultPath())) {
number++
}
return resultPath()
screenshot_number++
return `${test_file_name()}/${t.browser.name}/${t.test.name}-${screenshot_number}.png`
}

export async function screencap(t: TestController): Promise<void> {
Expand Down Expand Up @@ -164,6 +162,7 @@ export function urbanstatsFixture(name: string, url: string, beforeEach: undefin
return fixture(name)
.page(url)
.beforeEach(async (t) => {
screenshot_number = 0
await t.eval(() => { localStorage.clear() })
await t.resizeWindow(1400, 800)
await t.eval(() => { location.reload() })
Expand Down

0 comments on commit ba025de

Please sign in to comment.