mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-13 17:14:02 +03:00
6d491f928d
This configuration option allows to set a string with template values for precise control over snapshot path location. An example of `snapshotPathTemplate` usage: ```ts // playwright.config.ts // Notice the `testDir` configuration! export default { testDir: './tests', snapshotPathTemplate: './__screenshots__/{platform}/{projectName}/{testFilePath}/{arg}{ext}', } ``` Currently supported "magic tokens" inside the `snapshotPathTemplate` are: - `{testDir}` - project's `testDir` - `{snapshotDir}` - project's `snapshotDir` - `{platform}` - `process.platform` - `{projectName}` - Project's sanitized name - `{testFileDir}` - Directories in relative path from `testDir` to test file path (e.g. `page/` in the example below) - `{testFileName}` - Test file name (with extension) (e.g. `page-click.spec.ts` in the example below) - `{testFilePath}` - Relative path from `testDir` to test file path (e.g. `page/page-click.spec.ts` in the example below) - `{ext}` - snapshot extension (with dots) - `{arg}` - joined snapshot name parts, without extension (e.g. `foo/bar/baz` in the example below) - `{snapshotSuffix}` - `testInfo.snapshotSuffix` value. Consider the following file structure: ``` playwright.config.ts tests/ └── page/ └── page-click.spec.ts ``` The following `page-click.spec.ts`: ```ts // page-click.spec.ts import { test, expect } from '@playwright/test'; test('should work', async ({ page }) => { await expect(page).toHaveScreenshot(['foo', 'bar', 'baz.png']); }); ``` Fixes #7792 |
||
---|---|---|
.. | ||
fixture-scripts | ||
android-types.spec.ts | ||
connect-to-selenium.spec.ts | ||
docker-integration.spec.ts | ||
driver-should-work.spec.ts | ||
electron-types.spec.ts | ||
expect.d.ts | ||
globalSetup.ts | ||
npm-installs-local-packages.spec.ts | ||
npmTest.ts | ||
npx-global-help.spec.ts | ||
npx-global-install.spec.ts | ||
npx-global-spec-codegen.spec.ts | ||
playwright-cdn-failover-should-work.spec.ts | ||
playwright-cdn-should-race-with-timeout.spec.ts | ||
playwright-cli-codegen.spec.ts | ||
playwright-cli-install-should-work-with-languages.spec.ts | ||
playwright-cli-install-should-work.spec.ts | ||
playwright-cli-screenshot-should-work.spec.ts | ||
playwright-electron-should-work.spec.ts | ||
playwright-global-installation-cross-package.spec.ts | ||
playwright-global-installation.spec.ts | ||
playwright-global-subsequent-installs.spec.ts | ||
playwright-should-work-with-relative-browsers-path.spec.ts | ||
playwright-should-work-with-relative-home-path.spec.ts | ||
playwright-should-work.spec.ts | ||
playwright-test-should-work.spec.ts | ||
playwright-test-stacks-should-work.spec.ts | ||
playwright-xyz-should-work.spec.ts | ||
playwright.config.ts | ||
registry.ts | ||
screencast.spec.ts | ||
skip-browser-download-inspect-with-custom-executable.spec.ts | ||
skip-browser-download.spec.ts | ||
spawnAsync.ts | ||
typescript-types.spec.ts | ||
validate-dependencies.spec.ts |