Skip to content

Prevent async describe #18

@louy

Description

@louy

Thanks for this great plugin!

A mistake I've seen some people make is using an async function for describe, which then makes jest fail silently for a case like the following:

describe('sample case', () => {
  it('works', () => {
    expect(true).toEqual(true);
  });
  describe('async', async () => {
    await new Promise(setImmediate);
    it('breaks', () => {
      throw new Error('Fail');
    });
  });
});

It would be nice to have a rule that prevents this. Same would go for returning a promise (or any other value) inside describe.

describe('sample case', () => {
  it('works', () => {
    expect(true).toEqual(true);
  });
  describe('async', () => {
    return Promise.resolve().then(() => {
      it('breaks', () => {
        throw new Error('Fail');
      });
    });
  });
});

What do you guys think?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions