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

Use `describe` names for the suite name

Open VladimirCW opened this issue 3 years ago • 1 comments

I want to have possibility to use sub suites - so the full test name will contain the whole root suite names from the describe name

So for the following test 4 test should be created For now it will be only 2 tests

describe('Root suite', () => {

  describe('Nested root suite 1', () => {
    it('first assert', async () => {
      expect(true).toEqual(true);
    });
  });

  it('second assert', async () => {
    expect(true).toEqual(true);
  });

  describe('Nested suite 2', () => {
    it('first assert', async () => {
      expect(true).toEqual(true);
    });

    it('second assert', async () => {
      expect(true).toEqual(false);
    });
  });
});

VladimirCW avatar Apr 30 '21 12:04 VladimirCW

Hey @VladimirCW 👋🏻

Thanks for opening this feature request. I agree support for describe blocks would be great for the project. I'm currently preparing for a move to Seattle so my time will be limited for the next month. However if nobody else happens to open a PR for it, then I will do my best to get this in before September.

In the mean time I thought I'd leave some notes here on how this could be implemented:

One interesting way i've seen this implemented is in the Allure Jasmine library. They solve this by collecting the describe layers via Jasmine's suiteStarted and suiteDone hooks. The equivalent of this hook would be the start_describe_definition and finish_describe_definition jest environment events.

Something like this could allow us to detect wether the test is in fact wrapped in a describe block. Then we can collect the layers of describe block. Then once the finish_describe_definition is called for that block we would remove it from the collection. All while supporting nested describe blocks, and not effecting current implementation that supports tests without describe blocks.

ryparker avatar Jun 21 '21 07:06 ryparker