Pattern: Expect outside test block
Issue: -
Using expect statements outside of test blocks (it or test) prevents proper test execution and reporting. Helper functions containing expect statements are allowed.
Example of incorrect code:
describe("suite", () => {
expect(value).toBe(true);
});
expect(result).toEqual(expected);
Example of correct code:
describe("suite", () => {
it("test case", () => {
expect(value).toBe(true);
});
});
const checkValue = () => {
expect(value).toBe(true);
};