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

Possible Report inconsistencies when using beforeEach #3

Open
LisBerndt opened this issue May 10, 2023 · 2 comments
Open

Possible Report inconsistencies when using beforeEach #3

LisBerndt opened this issue May 10, 2023 · 2 comments

Comments

@LisBerndt
Copy link

LisBerndt commented May 10, 2023

Hello!
I know, this proejct is in its early phase, but it would be nice if you will have a look on the following issue:

When using a beforeEach like this:

test.describe("foo", () => {
  test.beforeEach(async ({ page }) => {
    await test.step("Do this first", async () => {
       //I let test already fail here...
    });
  });


  test("And then do this", async ({
    page,
  }, testInfo) => {
    testInfo.annotations.push({ type: "test_key", description: "Ticket-xxx" });
     // ... so that this part will not be executed.
});

Then no test_key property will be provided in the report.

My current workaround is as follows:

test.describe("foo", () => {
    test.beforeEach(async ({ page }, testInfo) => {
    testInfo.annotations.push({
      type: "test_key",
      description: "TICKET-PLACEHOLDER",
    });
    await test.step("Do this first", async () => {
        //I let test already fail here...
    });
  });

and then use a script to edit the report retroactively, so:

...
<properties>
<property name="test_key" value="Ticket-xxx">
</property>
<property name="test_key" value="Ticket-xxx">
</property>
<property name="testrun_evidence">
</property>
</properties>
...

Not nice, but sufficient.

Maybe there is a programmatic solution that could be provided by you?

@LisBerndt LisBerndt changed the title Report inconsistencies when using beforeEach Possible Report inconsistencies when using beforeEach May 10, 2023
@bitcoder
Copy link
Contributor

I don't know how to overcome this.. it's a consequence of the fact that we cannot add tags in Playwright in a clean way, unless we add them in the test title itself which IMO is messy. Other frameworks suffer also from this.
Adding the annotations on a beforeEach should work but even that is not very clean.
On the workaround you shared, Im not sure why you need to edit the report retroactively.. aren't the properties filled by the reporter?

@LisBerndt
Copy link
Author

On the workaround you shared, Im not sure why you need to edit the report retroactively.. aren't the properties filled by the reporter?

That's my main problem: If I do not, and the beforeEach fails, there is no value for test_key provided...

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

No branches or pull requests

2 participants