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

feat(config): snapshotPathTemplate as optional funtion #34127

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ShaMan123
Copy link

@ShaMan123 ShaMan123 commented Dec 21, 2024

closes #33098
replaces #33420

This PR adds to possibility to pass a function to snapshotPathTemplate, allowing full runtime control over snapshot names.

    // playwright.config.ts
    import { defineConfig } from '@playwright/test';

    export default defineConfig({
      testDir: './tests',
      snapshotPathTemplate: ({ testDir, testFilePath, arg, ext }) => 
            `${testDir}/__screenshots__/${testFilePath}/${arg}${ext}`,
    });

I am not sure the name fits this functionality so it might be better to add this as a standalone option.

@ShaMan123 ShaMan123 force-pushed the feat/snapshotPathTemplate-function#33098 branch from 410a7f5 to c88e21a Compare December 21, 2024 12:28

This comment has been minimized.

@ShaMan123 ShaMan123 force-pushed the feat/snapshotPathTemplate-function#33098 branch from c88e21a to 1da4ae1 Compare December 21, 2024 13:07
Copy link
Author

@ShaMan123 ShaMan123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functionality is stable, docs aren't

@@ -1751,7 +1751,7 @@ await Expect(Page.GetByTitle("Issues count")).toHaveText("25 issues");
```

## test-config-snapshot-path-template
- `type` ?<[string]>
- `type` ?<[string]|[SnapshotPathResolver]>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do I import SnapshotPathResolver into the generated .d.ts file?

This comment has been minimized.

@ShaMan123
Copy link
Author

@microsoft-github-policy-service agree

@ShaMan123 ShaMan123 force-pushed the feat/snapshotPathTemplate-function#33098 branch from 1da4ae1 to 4d0db50 Compare December 21, 2024 13:18

This comment has been minimized.

Copy link
Contributor

Test results for "tests 1"

3 fatal errors, not part of any test
46 failed
❌ [playwright-test] › expect.spec.ts:216:5 › should work with default expect matchers and esModuleInterop=false @macos-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:793:7 › directory imports › should resolve index.js after path mapping in CJS @macos-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:834:7 › directory imports › should resolve index.js after path mapping in ESM @macos-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:878:7 › directory imports › should respect package.json#main after path mapping in CJS @macos-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:925:7 › directory imports › should respect package.json#main after path mapping in ESM @macos-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:971:7 › directory imports › should respect package.json#exports without path mapping in CJS @macos-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:1013:7 › directory imports › should respect package.json#exports without path mapping in ESM @macos-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:1055:7 › directory imports › should not respect package.json#exports after type mapping in CJS @macos-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:1107:7 › directory imports › should not respect package.json#exports after type mapping in ESM @macos-latest-node18-1
❌ [playwright-test] › expect.spec.ts:216:5 › should work with default expect matchers and esModuleInterop=false @ubuntu-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:793:7 › directory imports › should resolve index.js after path mapping in CJS @ubuntu-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:834:7 › directory imports › should resolve index.js after path mapping in ESM @ubuntu-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:878:7 › directory imports › should respect package.json#main after path mapping in CJS @ubuntu-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:925:7 › directory imports › should respect package.json#main after path mapping in ESM @ubuntu-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:971:7 › directory imports › should respect package.json#exports without path mapping in CJS @ubuntu-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:1013:7 › directory imports › should respect package.json#exports without path mapping in ESM @ubuntu-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:1055:7 › directory imports › should not respect package.json#exports after type mapping in CJS @ubuntu-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:1107:7 › directory imports › should not respect package.json#exports after type mapping in ESM @ubuntu-latest-node18-1
❌ [playwright-test] › expect.spec.ts:216:5 › should work with default expect matchers and esModuleInterop=false @ubuntu-latest-node20-1
❌ [playwright-test] › resolver.spec.ts:793:7 › directory imports › should resolve index.js after path mapping in CJS @ubuntu-latest-node20-1
❌ [playwright-test] › resolver.spec.ts:834:7 › directory imports › should resolve index.js after path mapping in ESM @ubuntu-latest-node20-1
❌ [playwright-test] › resolver.spec.ts:878:7 › directory imports › should respect package.json#main after path mapping in CJS @ubuntu-latest-node20-1
❌ [playwright-test] › resolver.spec.ts:925:7 › directory imports › should respect package.json#main after path mapping in ESM @ubuntu-latest-node20-1
❌ [playwright-test] › resolver.spec.ts:971:7 › directory imports › should respect package.json#exports without path mapping in CJS @ubuntu-latest-node20-1
❌ [playwright-test] › resolver.spec.ts:1013:7 › directory imports › should respect package.json#exports without path mapping in ESM @ubuntu-latest-node20-1
❌ [playwright-test] › resolver.spec.ts:1055:7 › directory imports › should not respect package.json#exports after type mapping in CJS @ubuntu-latest-node20-1
❌ [playwright-test] › resolver.spec.ts:1107:7 › directory imports › should not respect package.json#exports after type mapping in ESM @ubuntu-latest-node20-1
❌ [playwright-test] › expect.spec.ts:216:5 › should work with default expect matchers and esModuleInterop=false @ubuntu-latest-node22-1
❌ [playwright-test] › resolver.spec.ts:793:7 › directory imports › should resolve index.js after path mapping in CJS @ubuntu-latest-node22-1
❌ [playwright-test] › resolver.spec.ts:834:7 › directory imports › should resolve index.js after path mapping in ESM @ubuntu-latest-node22-1
❌ [playwright-test] › resolver.spec.ts:878:7 › directory imports › should respect package.json#main after path mapping in CJS @ubuntu-latest-node22-1
❌ [playwright-test] › resolver.spec.ts:925:7 › directory imports › should respect package.json#main after path mapping in ESM @ubuntu-latest-node22-1
❌ [playwright-test] › resolver.spec.ts:971:7 › directory imports › should respect package.json#exports without path mapping in CJS @ubuntu-latest-node22-1
❌ [playwright-test] › resolver.spec.ts:1013:7 › directory imports › should respect package.json#exports without path mapping in ESM @ubuntu-latest-node22-1
❌ [playwright-test] › resolver.spec.ts:1055:7 › directory imports › should not respect package.json#exports after type mapping in CJS @ubuntu-latest-node22-1
❌ [playwright-test] › resolver.spec.ts:1107:7 › directory imports › should not respect package.json#exports after type mapping in ESM @ubuntu-latest-node22-1
❌ [playwright-test] › expect.spec.ts:216:5 › should work with default expect matchers and esModuleInterop=false @windows-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:793:7 › directory imports › should resolve index.js after path mapping in CJS @windows-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:834:7 › directory imports › should resolve index.js after path mapping in ESM @windows-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:878:7 › directory imports › should respect package.json#main after path mapping in CJS @windows-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:925:7 › directory imports › should respect package.json#main after path mapping in ESM @windows-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:971:7 › directory imports › should respect package.json#exports without path mapping in CJS @windows-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:1013:7 › directory imports › should respect package.json#exports without path mapping in ESM @windows-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:1055:7 › directory imports › should not respect package.json#exports after type mapping in CJS @windows-latest-node18-1
❌ [playwright-test] › resolver.spec.ts:1107:7 › directory imports › should not respect package.json#exports after type mapping in ESM @windows-latest-node18-1
❌ [playwright-test] › snapshot-path-template.spec.ts:109:5 › supports function arg @windows-latest-node18-1

10 flaky ⚠️ [firefox-page] › page/page-evaluate.spec.ts:403:3 › should throw for too deep reference chain @firefox-ubuntu-22.04-node18
⚠️ [webkit-library] › library/browsercontext-clearcookies.spec.ts:92:3 › should remove cookies by domain @webkit-ubuntu-22.04-node18
⚠️ [webkit-library] › library/browsercontext-har.spec.ts:244:3 › should round-trip har.zip @webkit-ubuntu-22.04-node18
⚠️ [webkit-library] › library/proxy.spec.ts:44:3 › should use proxy for second page @webkit-ubuntu-22.04-node18
⚠️ [webkit-library] › library/proxy.spec.ts:93:11 › should proxy local network requests › by default › loopback address @webkit-ubuntu-22.04-node18
⚠️ [webkit-library] › library/trace-viewer.spec.ts:109:1 › should show tracing.group in the action list with location @webkit-ubuntu-22.04-node18
⚠️ [webkit-library] › library/video.spec.ts:165:5 › screencast › should work with old options @webkit-ubuntu-22.04-node18
⚠️ [webkit-page] › page/page-leaks.spec.ts:161:5 › waitFor should not leak @webkit-ubuntu-22.04-node18
⚠️ [webkit-page] › page/page-set-input-files.spec.ts:205:3 › should upload multiple large files @webkit-ubuntu-22.04-node18
⚠️ [playwright-test] › ui-mode-test-watch.spec.ts:145:5 › should watch all @windows-latest-node18-1

37198 passed, 645 skipped
✔️✔️✔️

Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: snapshotPathTemplate as optional function
1 participant