-
Notifications
You must be signed in to change notification settings - Fork 248
Closed
Description
Recently I found out that instead of repeating expect.hasAssertions() in each test, you can have a single beforeEach(expect.hasAssertions) call at the top of the file.
It would be great if prefer-expect-assertions could detect file-level beforeEach(expect.hasAssertions) call and NOT give warnings in this case.
Current behavior:
beforeEach(expect.hasAssertions);
test("foo", () => {
// Warning: Every test should have either `expect.assertions(<number of assertions>)`
// or `expect.hasAssertions()` as its first expression
});beforeEach(() => {
expect.hasAssertions();
someOtherFunction();
});
test("foo", () => {
// Warning: Every test should have either `expect.assertions(<number of assertions>)`
// or `expect.hasAssertions()` as its first expression
});Expected behavior:
beforeEach(expect.hasAssertions);
test("foo", () => {
// No warnings
});beforeEach(() => {
expect.hasAssertions();
someOtherFunction();
});
test("foo", () => {
// No warnings
});NCarteazy