Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(test info): Add possibility to use test file name without extenson in snapshotPathTemplate #33420

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SishaMafonov
Copy link

Description

At the moment there is no possibility to get test file name without the extension for snapshotPathTemplate. Please refer to #24171

Our stakeholders requested to have path to snapshots without test file extension because it is confusing for them. The best place to achieve that is PW framework repo rather than custom fixtures in the project.

What was done

  • Add new token for the snapshotPathTemplate to cut out extension for the test file name
  • Add new token into the tests for the snapshotPathTemplate
  • Add information about the new token to the declarations
  • Add information about the new token into the public documentation

Testing

Screenshot - 11_4_2024 , 9_13_17 AM

@SishaMafonov
Copy link
Author

SishaMafonov commented Nov 4, 2024

@microsoft-github-policy-service agree

@SishaMafonov SishaMafonov force-pushed the feat/snapshot-path-without-extension branch from 8b64b1a to 5eb044d Compare November 4, 2024 08:21

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Nov 4, 2024

Test results for "tests 1"

3 flaky ⚠️ [chromium-page] › page/page-event-popup.spec.ts:149:3 › should not treat navigations as new popups @ubuntu-20.04-chromium-tip-of-tree
⚠️ [playwright-test] › ui-mode-test-update.spec.ts:202:5 › should update test locations @ubuntu-latest-node20-1
⚠️ [playwright-test] › ui-mode-test-watch.spec.ts:145:5 › should watch all @windows-latest-node18-1

36783 passed, 630 skipped
✔️✔️✔️

Merge workflow run.

@@ -454,6 +454,7 @@ export class TestInfoImpl implements TestInfo {
.replace(/\{(.)?projectName\}/g, projectNamePathSegment ? '$1' + projectNamePathSegment : '')
.replace(/\{(.)?testName\}/g, '$1' + this._fsSanitizedTestName())
.replace(/\{(.)?testFileName\}/g, '$1' + parsedRelativeTestFilePath.base)
.replace(/\{(.)?testFileNameWithoutExtension\}/g, '$1' + parsedRelativeTestFilePath.base.replace('.spec', '').replace('.ts', ''))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also at least *.spec.js, *.spec.tsx, *.spec.jsx, and same with .test. in the name.

@@ -79,6 +79,9 @@ test('tokens should expand property', async ({ runInlineTest }, testInfo) => {
}, {
name: 'testFileName',
snapshotPathTemplate: '{testFileName}',
}, {
name: 'testFileNameWithoutExtension',
snapshotPathTemplate: '{testFileNameWithoutExtension}',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual expects need to be extended too to cover various use cases of the new token.

@dgozman
Copy link
Contributor

dgozman commented Nov 20, 2024

@SishaMafonov Do you plan to update this PR and get it merged, or should I close it?

@SishaMafonov
Copy link
Author

@SishaMafonov Do you plan to update this PR and get it merged, or should I close it?

I apologize for the delay. I am planning to update it shortly. I apologize for inconvenience.

@ShaMan123
Copy link

IMO this is a use case of #33098, proving it has interest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants