@digest/jest

Digested Jest configurations

Usage no npm install needed!

<script type="module">
  import digestJest from 'https://cdn.skypack.dev/@digest/jest';
</script>

README

Digest Crane

@digest/jest

Commitizen Friendly Semantic Release
Build Status Coverage Report NPM Version License Canonical Code Style

@digest/jest provides a Jest configuration that works with Babel, and optionally React and Typescript. To use the provided Jest configuration, simply include the following scripts in your package.json:

"/package.json"

{
    ...
    "scripts": {
        ...
        "test": "jest --config node_modules/@digest/jest/dist/jest.config.js --no-cache --coverage",
        "test:dev": "jest --config node_modules/@digest/jest/dist/jest.config.js --no-cache --watch"
    }
}

If you are using react or typescript, don't forget to include the @digest/jest-react or @digest/jest-typescript packages.

The following optional properties are provided for additional configuration in your digest.config.json or environment variables:

digest.config.js Environment Variable Description Default Options
n/a DIGEST Path to Webpack Digest settings. It contains these settings. /webpack.digest.config.js
config CONFIG Path to Webpack config. /webpack.config.js or default config from Webpack Digest
reportPath REPORT_PATH Path to generate reports /reports
testConfig TESTCONFIG Path to optional script that is picked up by the provided Jest config to setup additional test suites such as enzyme /testconfig.js
tsconfig TSCONFIG Path to TypeScript config /tsconfig.json or defaults packaged with Webpack Digest

The TESTCONFIG option is for additional test suite configuration when using the provided Jest config. By default it will look for a testconfig.js file in the root of the project. This file is run via Jest's setupFiles option. This is required when using some libraries like enzyme. For example:

"/testconfig.js"

import {configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

configure({adapter: new Adapter()});

// For async tests, catch all errors here so we don't have to try / catch
// everywhere for safety
process.on('unhandledRejection', (error) => {
    console.log(error)
})

Remember, this file is not provided by default since it can be quite unique to each project.

License

GPLv3