Configurations exported with this package will set up the following jest
projects:
format: Check code style with prettier using jest-runner-prettier.
integration: Tests that run out of the integration-tests directory.
Functionally not much different than unit, but you can have a separate
configuration, different pipeline dependencies, etc.
lint: Run eslint checks using jest-runner-eslint.
unit: Need I say more?
Running jest will run all four projects. You can run a subset of the
projects using jest's --selectProjects argument, as usual.
If you need to, you can extend or wrap the configs generated here by calling
the config you want and passing an object as an argument that describes your
modifications. The object can have any combination of the following keys:
format: Specify extensions or wrappers for the format project.
global: Specify extensions or wrappers for the top-level jest config.
integration: Specify extensions or wrappers for the integration project.
lint: Specify extensions or wrappers for the lint project.
unit: Specify extensions or wrappers for the unit project.
The value for each of those keys should be an object containing either or
both of config, an object whose values will be spread into the relevant
project or global config, and wrapper, a function that should take the
config and return a promise containing the final config. For example:
Note that the extensions will be spread before calling the wrapper (so the
values in the config option will be present in the argument to the
wrapper).
This package contains a set of jest configs that set up runners for running unit tests, integration tests, eslint, and prettier.
Installing
Use the package manager of your choice to install:
npm install --save-dev @cprussin/jest-config
pnpm add -D @cprussin/jest-config
yarn add -D @cprussin/jest-config
Usage
jest.config.js
, for example:Run
jest
to run format checks, lint checks, unit tests, and integration tests, or use--selectProjects
to run a subset of checks.Add scripts to your
package.json
if you'd like. For instance:Projects
Configurations exported with this package will set up the following jest projects:
format
: Check code style with prettier usingjest-runner-prettier
.integration
: Tests that run out of theintegration-tests
directory. Functionally not much different thanunit
, but you can have a separate configuration, different pipeline dependencies, etc.lint
: Run eslint checks usingjest-runner-eslint
.unit
: Need I say more?Running
jest
will run all four projects. You can run a subset of the projects using jest's--selectProjects
argument, as usual.Options
If you need to, you can extend or wrap the configs generated here by calling the config you want and passing an object as an argument that describes your modifications. The object can have any combination of the following keys:
format
: Specify extensions or wrappers for theformat
project.global
: Specify extensions or wrappers for the top-level jest config.integration
: Specify extensions or wrappers for theintegration
project.lint
: Specify extensions or wrappers for thelint
project.unit
: Specify extensions or wrappers for theunit
project.The value for each of those keys should be an object containing either or both of
config
, an object whose values will be spread into the relevant project or global config, andwrapper
, a function that should take the config and return a promise containing the final config. For example:Note that the extensions will be spread before calling the wrapper (so the values in the
config
option will be present in the argument to thewrapper
).