GithubHelp home page GithubHelp logo

eslint-plugin-jest-mock-config's Introduction

eslint-plugin-jest-mock-config

ESLint rules for mocking using

Rules

This Plugin currently contains the following ESLint rules:

Name Description Documentation
jest-mock-without-import Reports jest.mock(<path>), when no import of <path> exitsts Link
jest-mocked-without-mock Reports jest.mocked(<function>), when the import of <function> is not mocked via jest.mock Link

Installation

# npm
npm install --safe-dev eslint-plugin-jest-mock-config

#yarn
yarn add --dev eslint-plugin-jest-mock-config

Additional note

Of cource this works for absolute and relative paths. Decide on your own, if ignoring relative paths is useful!

Development

Tests

npm test

Usage

When to use the plugin

If you are using jest with JavaScript or TypeScipt for your tests with .mockReturnValue / .mockResolvedValue / etc and want to detect wrong configurations of your jest mocks.

When to not use the plugin

  • If you are not using jest in your project
  • If you are ONLY using jest without .mockReturnValue / .mockResolvedValue / etc. and just mocking the import of the file in jest.mock as second parameter, e.g.:
jest.mock('/some/path', () => ({ someFunction: () => { ... } }))

ESLint7 / 8 / 9 compatibility

Rules included in this ESLint plugin are tested with Version 7 / 8 and 9 of ESLint. Please report bugs here, if you still encounter some.

eslint-plugin-jest-mock-config's People

Contributors

buzz-t avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.