question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to add labels to skipped/failed tests

See original GitHub issue

Hello!

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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Lucian-Gacommented, Feb 2, 2022

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?

describe('testSuite', () => {
beforeEach(() => {
  cy.allure().label('labelName', 'labelValue');
});

it('test name', () => {
    cy.allure().label('labelName', 'labelValue');
    <test contents>
    });
});
0reactions
Shelexcommented, Feb 2, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

auto add label on the giver PR if ta test fails or not. #35 - GitHub
The Tests failed label will be added to the PR if tests fail and there are any changes in the PR. Could you...
Read more >
Label your tests with advanced JUnit annotations
For example: @Ignore(“Disabled as this fails every Tuesday and it seems to be re-testing unnecessarily”).
Read more >
Test case statuses Passed, Skipped, Blocked, Retest, Failed ...
I have a test run and in some test cases which failed it is difficult to decide if a test case should be...
Read more >
skip detox tests on api failure - Stack Overflow
I was trying to skip the tests based on API failure for detox tests in which I am using jest as test runner...
Read more >
Debugging Failing Tests and Test Pipelines - GitLab
Please use this step if there are no issues created to capture the failure. If there is already an issue please skip this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found