Skip to content

Files

Latest commit

 

History

History
31 lines (23 loc) · 581 Bytes

no-standalone-expect.md

File metadata and controls

31 lines (23 loc) · 581 Bytes

Pattern: Expect outside test block

Issue: -

Description

Using expect statements outside of test blocks (it or test) prevents proper test execution and reporting. Helper functions containing expect statements are allowed.

Examples

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);
};