playwright/packages
Andrey Lushnikov 6d491f928d
feat(playwright-test): introduce snapshotPathTemplate configuration (#18568)
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
2022-11-09 15:29:07 -08:00
..
html-reporter chore: support dark theme in recorder & tv (#18389) 2022-10-27 16:50:41 -07:00
playwright chore: cut v1.27.0 (#17859) 2022-10-05 15:30:35 -07:00
playwright-chromium chore: cut v1.27.0 (#17859) 2022-10-05 15:30:35 -07:00
playwright-core Revert "feat: send SIGTERM to webserver before SIGKILL'ing it. (#18220)" (#18661) 2022-11-09 09:18:33 -08:00
playwright-ct-react chore(ct): bump vite to v3.2.1 (#18427) 2022-10-31 08:58:11 -07:00
playwright-ct-solid chore(ct): bump vite to v3.2.1 (#18427) 2022-10-31 08:58:11 -07:00
playwright-ct-svelte chore(ct): bump vite to v3.2.1 (#18427) 2022-10-31 08:58:11 -07:00
playwright-ct-vue chore(ct): bump vite to v3.2.1 (#18427) 2022-10-31 08:58:11 -07:00
playwright-ct-vue2 chore(ct): bump vue to v2.7.13 (#18428) 2022-11-01 14:17:43 -07:00
playwright-firefox chore: cut v1.27.0 (#17859) 2022-10-05 15:30:35 -07:00
playwright-test feat(playwright-test): introduce snapshotPathTemplate configuration (#18568) 2022-11-09 15:29:07 -08:00
playwright-webkit chore: cut v1.27.0 (#17859) 2022-10-05 15:30:35 -07:00
protocol/src chore: use provided value for the generated test id (#18631) 2022-11-08 12:04:43 -08:00
recorder chore: use provided value for the generated test id (#18631) 2022-11-08 12:04:43 -08:00
trace/src chore: render typed locators in the trace viewer (#18166) 2022-10-18 19:23:40 -07:00
trace-viewer chore: use codemirror for editor (#18482) 2022-11-01 15:04:30 -07:00
web chore(recorder): explore using codemirror (#18529) 2022-11-03 09:55:23 -07:00
.eslintrc.js chore: don't write into stdout from the test runner, use reporters instead (#11367) 2022-01-12 19:52:40 -08:00