jest-allure
jest-allure copied to clipboard
Unable to use reporter in beforeAll() or beforeEach()
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?
Unfortunately it's not supported yet
If you will able to do pull request, I'll happy to look into it 👍
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.
https://github.com/zaqqaz/jest-allure/pull/35 Here is my vision of reporting beforeAll, look and comment pls.