jest-allure icon indicating copy to clipboard operation
jest-allure copied to clipboard

Unable to use reporter in beforeAll() or beforeEach()

Open CosminGramada opened this issue 6 years ago • 4 comments

I have my set of tests in Typescript, so to be able to use the global variable reporter is declare at the start of the file: declare var reporter: any;

And in my tests, everything works just fine and properly displayed in the end report:

describe('Describe', () => {
    test('test name', async () => {
        reporter.description('Description here');
        reporter.startStep('Start step');
        reporter.endStep();
    });
});

However if I have a beforeAll() or a beforeEach() method that's using the reporter I get warnings and nothing is saved in the end report.

console.warn node_modules/allure-js-commons/index.js:57
    allure-js-commons: Unexpected startStep() of <name here>. There is no parent step

Example:

describe('Describe', () => {

    beforeAll(async () => {
        reporter.startStep('Before all start step');
        reporter.endStep();
    });

    test('test name', async () => {
        reporter.description('Description here');
        reporter.startStep('Start step');
        reporter.endStep();
    });
});

Am I using it wrong? It's not supported? Are there any workarounds?

CosminGramada avatar Oct 24 '18 10:10 CosminGramada

Unfortunately it's not supported yet

zaqqaz avatar Mar 01 '19 09:03 zaqqaz

If you will able to do pull request, I'll happy to look into it 👍

zaqqaz avatar Mar 01 '19 09:03 zaqqaz

How do you envision this to work? How I'd see it, is that everything that's "reported" from beforeAll(), beforeEach(), afterEach() and afterAll() to wind up in every test that's depending on these functions. Not sure in where I can start, so any tips or hints would be greatly appreciated.

CosminGramada avatar Mar 01 '19 09:03 CosminGramada

https://github.com/zaqqaz/jest-allure/pull/35 Here is my vision of reporting beforeAll, look and comment pls.

denis-y-krasilnikov avatar Oct 02 '19 14:10 denis-y-krasilnikov