playwright/tests/installation
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
..
fixture-scripts feat: introduce docker integration (#16382) 2022-09-09 15:25:42 -07:00
android-types.spec.ts chore: port installation tests to @playwright/test (#13644) 2022-04-25 09:30:14 -07:00
connect-to-selenium.spec.ts test: run installation tests on all major platforms (#13742) 2022-04-26 11:09:49 -07:00
docker-integration.spec.ts feat(playwright-test): introduce snapshotPathTemplate configuration (#18568) 2022-11-09 15:29:07 -08:00
driver-should-work.spec.ts chore: port installation tests to @playwright/test (#13644) 2022-04-25 09:30:14 -07:00
electron-types.spec.ts chore: port installation tests to @playwright/test (#13644) 2022-04-25 09:30:14 -07:00
expect.d.ts feat(docker): use the __screenshots__ dir for snapshots by default (#17311) 2022-09-13 15:49:04 -07:00
globalSetup.ts feat: introduce docker integration (#16382) 2022-09-09 15:25:42 -07:00
npm-installs-local-packages.spec.ts test: run installation tests on all major platforms (#13742) 2022-04-26 11:09:49 -07:00
npmTest.ts feat(containers): implement global network tethering for playwright server (#17719) 2022-11-03 13:47:51 -07:00
npx-global-help.spec.ts chore: relax npm version constraint in installation tests (#16427) 2022-08-10 15:33:47 -07:00
npx-global-install.spec.ts chore: relax npm version constraint in installation tests (#16427) 2022-08-10 15:33:47 -07:00
npx-global-spec-codegen.spec.ts chore: relax npm version constraint in installation tests (#16427) 2022-08-10 15:33:47 -07:00
playwright-cdn-failover-should-work.spec.ts test: installation test for CDN failover (#14963) 2022-06-20 11:24:23 -07:00
playwright-cdn-should-race-with-timeout.spec.ts feat(install): connection timeout (#18161) 2022-10-19 13:06:35 -07:00
playwright-cli-codegen.spec.ts chore: port installation tests to @playwright/test (#13644) 2022-04-25 09:30:14 -07:00
playwright-cli-install-should-work-with-languages.spec.ts chore: fix language binding based install message (#18480) 2022-11-01 13:46:17 -07:00
playwright-cli-install-should-work.spec.ts chore: port installation tests to @playwright/test (#13644) 2022-04-25 09:30:14 -07:00
playwright-cli-screenshot-should-work.spec.ts test: run installation tests on all major platforms (#13742) 2022-04-26 11:09:49 -07:00
playwright-electron-should-work.spec.ts chore: port installation tests to @playwright/test (#13644) 2022-04-25 09:30:14 -07:00
playwright-global-installation-cross-package.spec.ts test: run installation tests on all major platforms (#13742) 2022-04-26 11:09:49 -07:00
playwright-global-installation.spec.ts test: run installation tests on all major platforms (#13742) 2022-04-26 11:09:49 -07:00
playwright-global-subsequent-installs.spec.ts test: run installation tests on all major platforms (#13742) 2022-04-26 11:09:49 -07:00
playwright-should-work-with-relative-browsers-path.spec.ts test: run installation tests on all major platforms (#13742) 2022-04-26 11:09:49 -07:00
playwright-should-work-with-relative-home-path.spec.ts test: run installation tests on all major platforms (#13742) 2022-04-26 11:09:49 -07:00
playwright-should-work.spec.ts test: run installation tests on all major platforms (#13742) 2022-04-26 11:09:49 -07:00
playwright-test-should-work.spec.ts test: run installation tests on all major platforms (#13742) 2022-04-26 11:09:49 -07:00
playwright-test-stacks-should-work.spec.ts chore: port installation tests to @playwright/test (#13644) 2022-04-25 09:30:14 -07:00
playwright-xyz-should-work.spec.ts test: run installation tests on all major platforms (#13742) 2022-04-26 11:09:49 -07:00
playwright.config.ts Revert "fix(pwt): compatibility in CWD with wrong casing (#16636)" (#17599) 2022-09-26 18:53:08 -07:00
registry.ts fix: installation tests on Node.js 18 (#13744) 2022-04-25 13:24:11 -07:00
screencast.spec.ts test: run installation tests on all major platforms (#13742) 2022-04-26 11:09:49 -07:00
skip-browser-download-inspect-with-custom-executable.spec.ts chore: port installation tests to @playwright/test (#13644) 2022-04-25 09:30:14 -07:00
skip-browser-download.spec.ts chore: port installation tests to @playwright/test (#13644) 2022-04-25 09:30:14 -07:00
spawnAsync.ts chore: port installation tests to @playwright/test (#13644) 2022-04-25 09:30:14 -07:00
typescript-types.spec.ts fix(esm): fix TS type check with NodeNext mode (#16340) 2022-08-09 20:06:06 +02:00
validate-dependencies.spec.ts test: run installation tests on all major platforms (#13742) 2022-04-26 11:09:49 -07:00