playwright/tests
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
..
android test: gardening (#18623) 2022-11-07 15:35:21 -08:00
assets test: unflake page-drag tests (#17783) 2022-10-03 12:26:36 -07:00
components test(ct): vue cli router (#18603) 2022-11-08 08:40:29 -08:00
config chore: use provided value for the generated test id (#18631) 2022-11-08 12:04:43 -08:00
electron test: electron firstWindow() does not work with delayed navigation (#18093) 2022-10-14 08:36:37 -07:00
installation feat(playwright-test): introduce snapshotPathTemplate configuration (#18568) 2022-11-09 15:29:07 -08:00
library fix(codegen): fix csharp options syntax (#18662) 2022-11-08 21:48:01 -08:00
page test: gardening (#18623) 2022-11-07 15:35:21 -08:00
playwright-test feat(playwright-test): introduce snapshotPathTemplate configuration (#18568) 2022-11-09 15:29:07 -08:00
stress fix(leak): do not retain test fixtures in worker fixtures (#14363) 2022-05-23 16:54:56 -07:00
webview2 test: add initial webview2 tests (#16827) 2022-09-07 20:09:22 +02:00
index.d.ts test: added tests for WebSocket over Socks proxy (#7235) 2021-06-24 18:50:16 +02:00
tsconfig.json chore: move protocol and trace types into the top-level packages (#17486) 2022-09-20 18:41:51 -07:00