-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
[Feature]: Ability to access custom TestDetails through TestInfo directly inside TestHook! #33855
Comments
Hi Hassan! I'm pretty sure there's an existing feature inside Playwright you can use to achieve what you're looking for. Could you elaborate on what you're trying to achieve? |
Hi! Thanks for your response. I'm looking for a way to access custom properties defined in the TestDetails object directly within TestInfo during the execution of a test. For example, if I define a test like this:
Currently, there's no straightforward way to access the (Custom) TestDetails through TestInfo, which will be helpful to inject these information directly inside custom test hooks and custom test fixtures. My goal is to have a built-in method (e.g., testInfo.details()) to access the TestDetails directly. This would allow: Access Inside Custom Fixtures: Being able to leverage these details when setting up or tearing down fixtures. Does Playwright already have a feature for this that I might have overlooked? I'd love to explore that if so! Thank you! 😊 |
Also I know something similar can be achieved using annotation:
But with my requested feature, it will be easier to write it concisely and make it more readable!
|
I think option fixtures are exactly what you need: https://playwright.dev/docs/test-fixtures#fixtures-options |
I'd vote for @MrVerifit proposal. I think, if there were per-test-fixtures implemented (see #27138), then fixture options would be a solution, because it would be possible to write: test("basic test", async ({ page, context }) => {
// ...
}).use({
database: [{ reset: false }, { option: true }]
}); For now, the workaround from the mentioned ticket should also work (although I personally not a fan of anonymous describe block): test.describe(() => {
test.use({ database: [{ reset: false }, { option: true }] });
test('basic test', async ({ page }) => {
// ...
});
}); |
🚀 Feature Request
I would like to request a way to access custom TestDetails inside testHook
Example
Accessing CustomTestDetails through TestInfo
Motivation
Currently, there is no way to access custom test details inside hooks/custom fixtures. A built-in testInfo.details() method will provide access CustomTestDetails for such scenario and would streamline such processes.
The text was updated successfully, but these errors were encountered: