Skip to content

no multiple done()s and writing custom rules #1867

@gaz7

Description

@gaz7

Some of our developers write tests with multiple done()s in them. This obviously isn't correct, as tests should run (and complete) the same way every time. An example might be:

myObservable$.subscribe({
  next: (result) => {
    expect(result).toBe('foo');
    done();
  },
  error: (err) => {
    done(): // this is wrong. it should fail the test if error happens
  }
});

Is there an existing rule that can catch this?

Whether this rule exists or not, I've been considering writing some custom lint rules for our codebase to handle our specific best practices.
Can we leverage some of the existing code/utilities in this lib to do that? If so, are there any guidelines?

Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions