Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Empty test result folders created when using toHaveScreenshot #15600

Closed
devkat opened this issue Jul 13, 2022 · 1 comment · Fixed by #24127
Closed

[BUG] Empty test result folders created when using toHaveScreenshot #15600

devkat opened this issue Jul 13, 2022 · 1 comment · Fixed by #24127
Assignees
Labels
feature-test-runner Playwright test specific issues v1.36

Comments

@devkat
Copy link
Contributor

devkat commented Jul 13, 2022

Context:

  • Playwright Version: 1.23.2
  • Operating System: Linux, Mac

Code Snippet

await expect(page).toHaveScreenshot()

Describe the bug

When using toHaveScreenshot, Playwright creates an empty directory for the test under test-results, even if the test succeeds.

The cause is probably this line:

https://github.com/microsoft/playwright/blob/main/packages/playwright-test/src/testInfo.ts#L240

  outputPath(...pathSegments: string[]){
    fs.mkdirSync(this.outputDir, { recursive: true });

SnapshotHelper.constructor calls outputPath:

https://github.com/microsoft/playwright/blob/main/packages/playwright-test/src/matchers/toMatchSnapshot.ts#L129

    const inputFile = testInfo.outputPath(...inputPathSegments);

See also: https://en.wikipedia.org/wiki/Command%E2%80%93query_separation

@yury-s yury-s added P3-collecting-feedback feature-test-runner Playwright test specific issues labels Jul 13, 2022
@drwpow
Copy link

drwpow commented Aug 13, 2022

I had to write a script to clean up empty folders after Playwright runs for this reason. In CI it doesn’t really matter too much, but locally it can be hard to find the snapshot diffs with all the empty folders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-test-runner Playwright test specific issues v1.36
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants