Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/src/api/params.md
Original file line number Diff line number Diff line change
Expand Up @@ -1933,6 +1933,8 @@ The list of supported tokens:
* Value: `/home/playwright/tests` (absolute path since `testDir` is resolved relative to directory with config)
* `{testFileDir}` - Directories in relative path from `testDir` to **test file**.
* Value: `page`
* `{testFileBaseName}` - Test file name without the last extension.
* Value: `page-click.spec`
* `{testFileName}` - Test file name with extension.
* Value: `page-click.spec.ts`
* `{testFilePath}` - Relative path from `testDir` to **test file**.
Expand Down
1 change: 1 addition & 0 deletions packages/playwright/src/worker/testInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ export class TestInfoImpl implements TestInfo {
.replace(/\{(.)?platform\}/g, '$1' + process.platform)
.replace(/\{(.)?projectName\}/g, projectNamePathSegment ? '$1' + projectNamePathSegment : '')
.replace(/\{(.)?testName\}/g, '$1' + this._fsSanitizedTestName())
.replace(/\{(.)?testFileBaseName\}/g, '$1' + parsedRelativeTestFilePath.name)
.replace(/\{(.)?testFileName\}/g, '$1' + parsedRelativeTestFilePath.base)
.replace(/\{(.)?testFilePath\}/g, '$1' + relativeTestFilePath)
.replace(/\{(.)?arg\}/g, '$1' + nameArgument)
Expand Down
4 changes: 4 additions & 0 deletions packages/playwright/types/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,8 @@ interface TestProject<TestArgs = {}, WorkerArgs = {}> {
* config)
* - `{testFileDir}` - Directories in relative path from `testDir` to **test file**.
* - Value: `page`
* - `{testFileBaseName}` - Test file name without the last extension.
* - Value: `page-click.spec`
* - `{testFileName}` - Test file name with extension.
* - Value: `page-click.spec.ts`
* - `{testFilePath}` - Relative path from `testDir` to **test file**.
Expand Down Expand Up @@ -1770,6 +1772,8 @@ interface TestConfig<TestArgs = {}, WorkerArgs = {}> {
* config)
* - `{testFileDir}` - Directories in relative path from `testDir` to **test file**.
* - Value: `page`
* - `{testFileBaseName}` - Test file name without the last extension.
* - Value: `page-click.spec`
* - `{testFileName}` - Test file name with extension.
* - Value: `page-click.spec.ts`
* - `{testFilePath}` - Relative path from `testDir` to **test file**.
Expand Down
4 changes: 4 additions & 0 deletions tests/playwright-test/snapshot-path-template.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ test('tokens should expand property', async ({ runInlineTest }, testInfo) => {
}, {
name: 'testFileName',
snapshotPathTemplate: '{testFileName}',
}, {
name: 'testFileBaseName',
snapshotPathTemplate: '{testFileBaseName}',
}, {
name: 'snapshotDir',
snapshotDir: './a-snapshot-dir',
Expand All @@ -101,6 +104,7 @@ test('tokens should expand property', async ({ runInlineTest }, testInfo) => {
expect.soft(snapshotPath['testFileDir']).toBe(path.join('a', 'b', 'c'));
expect.soft(snapshotPath['testFilePath']).toBe(path.join('a', 'b', 'c', 'd.spec.ts'));
expect.soft(snapshotPath['testFileName']).toBe('d.spec.ts');
expect.soft(snapshotPath['testFileBaseName']).toBe('d.spec');
expect.soft(snapshotPath['snapshotDir']).toBe('a-snapshot-dir.png');
expect.soft(snapshotPath['snapshotSuffix']).toBe('-' + process.platform);
expect.soft(snapshotPath['testName']).toBe('suite-test-should-work');
Expand Down
Loading