#unit-testing #jest #lint #import #cli

app jest_lint

Lint your Jest unit tests to find problems

5 releases

0.1.4 Nov 4, 2024
0.1.3 Apr 19, 2024
0.1.2 Apr 19, 2024
0.1.1 Apr 19, 2024
0.1.0 Apr 19, 2024

#386 in Command line utilities

Download history 36/week @ 2024-07-24 10/week @ 2024-07-31 3/week @ 2024-09-18 3/week @ 2024-09-25 102/week @ 2024-10-30 40/week @ 2024-11-06

142 downloads per month

MIT license

12KB
245 lines

jest_lint

Lint your Jest unit tests to find problems. Built with Rust.

Right now this is a simple tool to check that you have mocked your imports. But if you have an idea for adding a new feature, feel free to suggest

If you want to ignore a region of imports (e.g. if you intentionally don't want to mock them), you can use a region: //#region not-mocked (see the samples dir for more context)

Getting started

First: Install Rust and Cargo

Then, either install the published create (easy) or download from this repo.

Install published crate (easy)

cargo install jest_lint
jest_lint --help

To test for mocks in all your files:

jest_lint -m

To test for mocks in files for a specific dir:

jest_lint -d path/to/files

To test for mocks in a single file:

jest_lint -m -f path/to/foobar.test.js

Latest development build

Download this repository.

cd jest_lint
cargo run -- --help

PRs welcome!

Tips & Tricks

If you're using VS Code, you can add a task to .vscode/tasks.json to run jest_lint on the current file:

{
  "label": "jest_lint",
  "type": "shell",
  "command": "jest_lint -mf ${file}"
}

Then you can use a keyboard shortcut to check your mocks while you have your .spec.* or .test.* file open.

Dependencies

~3–12MB
~124K SLoC