[qase-playwright-reporter] Support providing qase id's through annotations
complete
T
Taber Hust
## Request
We would like to be able to set Qase IDs through playwright custom annotations (https://playwright.dev/docs/test-annotations) rather than calling qase.id() within the test.
## Why are we requesting this
While the v2 approach of calling qase.id() within the test works fine in simple scenarios, it has a flaw in playwright for tests with more complex flows, particular those that leverage beforeEach(), playwright test fixtures (https://playwright.dev/docs/test-fixtures), or any built-in annotations (i.e. test.skip()).
### beforeEach()
If the test fails in the beforeEach() step, the test function is never run; therefore, qase.id() is never executed and the ID mapping is not provided (resulting in either an auto-created test OR that test remaining as "Untested" rather than "Failed" in the test run (depending on project settings
### Fixtures
Our team utilizes fixtures to centralize logic for the "starting" point of particular pages where tests should begin. This helps reduce repetitive code in every test that loads the page and performs a set of actions before the actual test logic can begin. If a test fails within a Fixture function (which happens in the Before Hooks of a test) the test function never executes, meaning qase.id() is never executed (same problem as beforeEach())
### test.skip()
If we use test.skip(), test.fixme(), etc. at the top level, this automatically skips the test, and the function never runs, meaning qase.id() is never run. We can get around this by moving the test.skip() call to inside the test function after qase.id() is executed, but this adds additional test run-time running fixtures and beforeEach() hooks for a test we never intend to run.
## How would annotations help?
In all of the above scenarios, qase.id() is not run because its embedded in a test function that never runs.
However, if the qase id were instead provided as a test annotation, it's not dependent on whether or not the test function is executed. Instead, it's added to the test's annotations in whenever the test is registered (before it even runs), meaning you could access it via the TestCase.annotations (https://playwright.dev/docs/api/class-testcase#test-case-annotations) within the reporter.
Here's an example of how this could work...
//my test ==> qase id (1)
myTestFixture('mytest',
{ annotation: { name: 'qase-id', description: '1' }}
async ({ myCustomPage }) => {
// I do not reach this point because myTestFixture fails when setting up myCustomPage
qase.id(1);
}
);
If the reporter could also check for annotation where name === "qase-id", even though qase.id(1) never executes, we could still properly map Qase ID 1 as failed in the test run.
Ilya Volkov
complete
Hi everyone!
The requested functionality has been delivered in the latest version of the playwright reporter, 2.0.14:
https://github.com/qase-tms/qase-javascript/blob/main/qase-playwright/changelog.md#playwright-qase-reporter2014
Please, consider upgrading the package to gain access to the new functional additions!
T
Taber Hust
Ilya Volkov thanks! It works great!