Skip to content

Files

Latest commit

 

History

History
24 lines (17 loc) · 502 Bytes

no-mocks-import.md

File metadata and controls

24 lines (17 loc) · 502 Bytes

Pattern: Direct mock import

Issue: -

Description

Importing directly from __mocks__ directory can lead to unexpected behavior. Jest's automatic mock handling should be used instead.

Examples

Example of incorrect code:

import mock from "./__mocks__/service";
const helper = require("./__mocks__/helper");

Example of correct code:

import service from "./service";
const helper = require("./helper");

jest.mock("./service");
jest.mock("./helper");