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

[Feature] Implement test.step for long test scenarios #7254

Closed
emakhachek opened this issue Jun 21, 2021 · 5 comments
Closed

[Feature] Implement test.step for long test scenarios #7254

emakhachek opened this issue Jun 21, 2021 · 5 comments
Assignees
Labels
feature-test-runner Playwright test specific issues

Comments

@emakhachek
Copy link

emakhachek commented Jun 21, 2021

Edit from maintainers: see this comment for feature description


Hi All,
I am currently using: jest, playwright, jest-playwright-preset.
Thanks to testRunner: “jest-circus/runner” I was able to override testEnvironment with a custom “fail fast” testEnvironment like it was mentioned here:
jestjs/jest#6527 (comment)
The goal is to fail the whole test suite (only one) if at least one test is failed (custom config for specific suite where all test are related to each other).
I found maxFailures: 1 option but it's shared between all projects.
I want this option to be applied only for one suite (test file) via setting maxFailures: 1 for one of the Projects combining with testIgnore or testDir options.
Thanks)

@emakhachek emakhachek changed the title Add maxFailures option to the Test suite options [Feature] Add maxFailures option to the Test suite options Jun 21, 2021
@aslushnikov
Copy link
Collaborator

aslushnikov commented Jun 22, 2021

@emakhachek (i assume we're talking about @playwright/test testrunner)

I want this option to be applied only for one suite (test file) via setting maxFailures: 1 for one of the Projects combining with testIgnore or testDir options.

It actually sounds like you use tests as "steps". So instead of having something like this that you try to configure with the custom "fail-fast" logic:

describe('test renting a car', () => {
  // SOMEHOW configure this to fail the whole test suite (only one)
  // if at least one test is failed
  test('step 1 - login', async () => { /* ... login workflow ... */ });
  test('step 2 - rent a car', async () => { /* ... rent a car sequence ... */ });
  test('step 3 - checkout', async () => { /* ... checkout cart ... */ });
  test('step 4 - check status', async () => { /* ... validate success ...*/ });
});

You actually will get the needed behavior with an explicit test.step() API:

test(`test renting a car`, async () => {
  await test.step('step 1 - login');
  /* ... login workflow ... */ 
  await test.step('step 2 - rent a car');
  /* ... rent a car sequence ... */ 
  await test.step('step 3 - checkout');
  /* ... checkout cart ... */
  await test.step('step 4 - check status');
  /* ... validate success ...*/ 
});

We don't have test.step implemented just yet - but we are collecting feedback if it is something worthy to add.
See also a suggestion for "optional" steps that continue the test even after the assertion failure: #7482 (comment).

Let us know if this is something you're looking for and you'd love to have implemented!

@aslushnikov aslushnikov added triaging feature-test-runner Playwright test specific issues labels Jun 22, 2021
@emakhachek
Copy link
Author

I like this solution more than to override test environment with a custom one. I hope anyone vote for it. Thanks)

@aslushnikov aslushnikov changed the title [Feature] Add maxFailures option to the Test suite options [Feature] Implement test.step for long test scenarios Jun 23, 2021
@bgotink
Copy link

bgotink commented Jun 23, 2021

This would be very interesting to have! Especially if the reporters know what steps succeeded / failed, so they can update the status of these steps in testware.

@mxschmitt
Copy link
Member

cc @ortoniKC might be interesting for you to subscribe to this issue. Since it makes it possible to split long tests into smaller parts while keeping the same page object.

@dgozman
Copy link
Contributor

dgozman commented Aug 11, 2021

#7956 implemented the following basic syntax:

test('my test', async ({ page }) => {
  await test.step('login', async () => {
    await page.goto('myurl');
    await page.fill('#username', 'username');
    await page.fill('#password', 'password');
    await page.click('text=Log in');
  });

  await test.step('another step', async () => {
    // ...
  });
});

See here: https://playwright.dev/docs/api/class-test#test-step

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-test-runner Playwright test specific issues
Projects
None yet
Development

No branches or pull requests

6 participants