-
Notifications
You must be signed in to change notification settings - Fork 8
feat: Add basic test steps support for 'test.step' category only #6
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
Conversation
apatelia
commented
Aug 27, 2024
- Tested with passed, failed, and skipped tests
|
Hello, thanks for your contribution. This change includes steps such as hooks and assertions whereas the CTRF steps property is intended specifically for BDD-style steps. Could I suggest that we limit the inclusion to playwright steps category "test.step"? |
|
I have filtered steps with test.step category only. |
- This fix will include steps from Background section of a BDD feature
|
Hello @apatelia, test('test with nested steps', async ({ page }) => {
await test.step('Navigate and validate Playwright homepage', async () => {
await test.step('Navigate to Playwright homepage', async () => {
await page.goto('https://playwright.dev/');
});
await test.step('Verify page title contains Playwright', async () => {
await expect(page).toHaveTitle(/Playwright/);
});
});
await test.step('Interact with the Get Started section', async () => {
await test.step('Click on Get Started link', async () => {
await page.getByRole('link', { name: 'Get started' }).click();
});
await test.step('Verify Installation heading is visible', async () => {
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
});
});
}); "steps": [
{
"name": "Navigate and validate Playwright homepage",
"status": "passed"
},
{
"name": "Interact with the Get Started section",
"status": "passed"
}
], |
|
Please update the README.md with the new supported property. |
- Update README to indicate 'steps' as a supported property of 'Test' object
|
Hello @Ma11hewThomas, Based on your earlier comment and CTRF schema doc, I (wrongly) assumed that the I have removed this category condition now while looking for child steps, so it iterates over the child steps of all types but includes steps having I have also updated README.md as requested. My tests were: A BDD scenario Feature: Products
Background:
Given the User is on login page
When the User tries to login with "standard_user" as username and "secret_sauce" as password
Then the User should be on Products page
Scenario: Test that the user is able to remove a product from the cart
When the user adds "Sauce Labs Bike Light" to the cart
Then the user should be able to remove "Sauce Labs Bike Light" from the cart, using the `Remove` button
Then the cart item badge must not be displayedwhich generated "steps": [
{
"name": "Given the User is on login page",
"status": "passed"
},
{
"name": "When the User tries to login with \"standard_user\" as username and \"secret_sauce\" as password",
"status": "passed"
},
{
"name": "Then the User should be on Products page",
"status": "passed"
},
{
"name": "When the user adds \"Sauce Labs Bike Light\" to the cart",
"status": "passed"
},
{
"name": "Then the user should be able to remove \"Sauce Labs Bike Light\" from the cart, using the `Remove` button",
"status": "passed"
},
{
"name": "Then the cart item badge must not be displayed",
"status": "passed"
}
]and a regular playwright test with nested steps (same as given by you above) test('test with nested steps', async ({ page }) => {
await test.step('Navigate and validate Playwright homepage', async () => {
await test.step('Navigate to Playwright homepage', async () => {
await page.goto('https://playwright.dev/');
});
await test.step('Verify page title contains Playwright', async () => {
await expect(page).toHaveTitle(/Playwright/);
});
});
await test.step('Interact with the Get Started section', async () => {
await test.step('Click on Get Started link', async () => {
await page.getByRole('link', { name: 'Get started' }).click();
});
await test.step('Verify Installation heading is visible', async () => {
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
});
});
});which generated "steps": [
{
"name": "Navigate and validate Playwright homepage",
"status": "passed"
},
{
"name": "Navigate to Playwright homepage",
"status": "passed"
},
{
"name": "Verify page title contains Playwright",
"status": "passed"
},
{
"name": "Interact with the Get Started section",
"status": "passed"
},
{
"name": "Click on Get Started link",
"status": "passed"
},
{
"name": "Verify Installation heading is visible",
"status": "passed"
}
] |
|
@Ma11hewThomas, one question. CTRF schema supports only flattened steps while BDD tests and Playwright tests both, support nested steps through For example, it won't be possible to generate HTML like below. |
|
Thank you for your contribution @apatelia! Appreciated! This has been published in v0.0.16 Regarding your question, this is a valid point and your expertise with BDD is valuable. Please can you raise this as a discussion for us to consider a change to the schema for steps. Thanks |
