Unable to add labels to skipped/failed tests
See original GitHub issueHello!
My team started using labels for cypress tests, but we ran into an issue. The labels we are trying to add are not showing up inside the allure raw results for tests that are either skipped or failing.
This is how we are trying to add labels to the tests
describe('testSuite', () => {
it('test name', () => {
cy.allure().label('labelName', 'labelValue');
<test contents>
});
});
The allure raw result json file will contain the following lines of labels if the test passes
"labels": [
{ "name": "suite", "value": "testSuite" },
{ "name": "labelName", "value": "labelValue" }
],
While the result for failing/skipped tests will only display the suite name, ignoring the label added inside the test.
"labels": [{ "name": "suite", "value": "testSuite" }],
I thought this could be a problem with reading the contents of the test itself thus being unable to add the label, but when using the same command to add the labels inside beforeEach it still did not work.
My expectation is that the labels are added regardless of the test result.
Versions Cypress: 7.7.0 cypress-allure-plugin: 2.23.0, 2.8.4
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top GitHub Comments
I checked again, and before/afterEach hooks are still not working for tests that are skipped using .skip. Without skipping the test, the label is added correctly. I’ve also tried this with the beforeEach outside describe. Can you please tell me if I am missing something?
Yes, you are correct. It seems that when your first test is skipped - beforeEach and afterEach hooks are not applied to it at all, they are executed later, so allure-plugin don’t have any labels when test is processed. I have seen multiple issues in Cypress repo for that matter, however they say it is not bug but feature. So in v2.25.1 I have added check for that and labels that were added in hooks (beforeEach\afterEach) will be applied to skipped tests if they still don’t have such labels.