@equisoft/jest-utils

0.0.1-snapshot.20230613025310 • Public • Published

@equisoft/jest-utils

This package regroup utils to help write tests with Jest and create a standard config.

How to install

yarn add -DE @equisoft/jest-utils

How to use

Create a jest config

Create your jest.config.js file and import the createJestConfig function. The createJestConfig uses a deep merge that allow you to extend from the base Equisoft's config.

// jest.config.js

const { createJestConfig } = require('@equisoft/jest-utils');
const { pathsToModuleNameMapper } = require('ts-jest');
const { compilerOptions } = require('./tsconfig.json');

const config = {
    moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths || [], { prefix: '<rootDir>/src/test' }),

    roots: [
        '<rootDir>/src/browser',
        '<rootDir>/src/test',
    ],
    setupFilesAfterEnv: [
        'jest-extended',
        './src/test/setup-tests.ts',
    ],

    collectCoverageFrom: ['<rootDir>/src/browser/**/*.{js,jsx,ts,tsx}'],

    transform: {
        '^.+.m?[t]sx?$': ['ts-jest', {
            tsconfig: 'src/test/tsconfig.json',
            babelConfig: {
                presets: [
                    ['@babel/preset-env', { targets: { node: 'current' } }],
                    '@babel/preset-react',
                ],
                plugins: [
                    '@babel/plugin-transform-react-display-name',
                    ['babel-plugin-styled-components', { fileName: false }],
                ],
            },
        },
        ],
    },
};

module.exports = createJestConfig(config);

Readme

Keywords

none

Package Sidebar

Install

npm i @equisoft/jest-utils

Weekly Downloads

926

Version

0.0.1-snapshot.20230613025310

License

none

Unpacked Size

6 kB

Total Files

10

Last publish

Collaborators

  • faroukhoumaidi
  • mcantinequi
  • christopherviel
  • jsgarneau
  • kbeaulieu
  • toby-daigle
  • kronostechnologies-build
  • etremblay
  • larrymatte
  • meriouma
  • agauthier