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.

There are no results in report when before hook fails and next block is describe() not it()

See original GitHub issue

Describe the bug The following code cause the issue

describe('one', () => {
	before(() => {
		expect(true).to.equal(false); // when before hook fails and the next block is describe
	});

	describe('second', () => {
		before(() => {
			expect(true).to.equal(true);
			cy.log('gg');
		});
		it('should log 2', () => {
			cy.log('log 2');
		});
	});
});

There is only container.json file in allure-results and no attachments

However when before hooks fails and the next block is it() it just works fine

describe('one', () => {
	before(() => {
		expect(true).to.equal(true); // pass
	});

	describe('second', () => {
		before(() => {
			expect(true).to.equal(false); // fails but there are results in report
			cy.log('gg');
		});
		it('should log 2', () => {
			cy.log('log 2');
		});
	});
});

Now allure-results folder contains result.json, container.json and attachments

Environment (please complete the following information):

  • Cypress version: 8.6.0
  • cypress allure plugin: 2.23.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
romankhomitskyicommented, Feb 1, 2022

Ok, thanks for replies and fix!!

1reaction
Shelexcommented, Jan 3, 2022

I would like to have these structure instead of splitting these describes into two specs

However that is exactly the core recommendation for designing tests - isolation 😃. Here you have admin and user functionality combined together. But it would be much easy to maintain, read and support when separated:

describe('User rent', () => {
    before(() => {
        // actions done via backend
        // create admin and user
    });

    beforeEach(() => {
        // create rent with value 100$ and share with user
        // login as user an accept rent
    });

    afterEach(() => {
        // remove rent
    });

    after(() => {
        // delete user
        // delete admin
    });

    it('should be able to display actual rent value', () => {
        expect(rent).to.be.eq(100);
    });

    it('should be able to display decreased rent value', () => {
        // via admin api decrease rent to 20
        expect(rent).to.be.eq(20);
    });

    it('should be able to display increased rent value', () => {
        // via admin api increase rent to 50
        expect(rent).to.be.eq(50);
    });
});

describe('Admin rent', () => {
    before(() => {
        // create admin
    });

    beforeEach(() => {
        // create rent with value 100
    });

    afterEach(() => {
        // remove rent
    });

    after(() => {
        // delete admin
    });

    it('should contain initial rent value', () => {
        expect(rent).to.be.eq(100);
    });

    it('should be able to decrease rent value', () => {
        // decrease rent to 20
        expect(rent).to.be.eq(20);
    });

    it('should be able to increase rent value', () => {
        // increase rent to 50
        expect(rent).to.be.eq(50);
    });
});

Moreover, it seems like functionality that should be covered with unit tests (or at least integration/component), instead of Cypress and e2e level.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Describe block with async function behaving weirdly #2975
In the "parsing" cycle all describe callbacks are excecuted and the test hierarchy ( runner ) is created. Those callbacks are indeed synchronous ......
Read more >
For async tests and hooks, ensure "done()" is called
I have this test of nodejs when testing I get a error of done function not declared. Error ...
Read more >
Mocha - the fun, simple, flexible JavaScript test framework
Mocha tests run serially, allowing for flexible and accurate reporting, while mapping uncaught exceptions to the correct test cases. Hosted on GitHub.
Read more >
Allure Reporter - WebdriverIO
A WebdriverIO reporter plugin to create Allure Test Reports. ... to not fetch the before/after stacktrace/screenshot/result hooks into the Allure Reporter.
Read more >
Jest Tutorial - JavaScript Unit Testing Using Jest Framework
Tips & Tricks; Video Tutorial: Jest Coverage & HTML Report Generation ... describe("Calculator tests", () => { test('adding 1 + 2 should ...
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