Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

jest-preset.js

46 lines1.1 KB

1const path = require('path')
2const { lstatSync, readdirSync } = require('fs')
3​
4// get listing of packages in the mono repo
5const basePath = path.resolve(__dirname, 'packages')
6const packages = readdirSync(basePath)
7 .filter((name) => {
8 return lstatSync(path.join(basePath, name)).isDirectory()
9 })
10 .sort((a, b) => b.length - a.length)
11​
12const { namespace } = require('./package.json')
13​
14const moduleNameMapper = {
15 ...packages.reduce(
16 (acc, name) => ({
17 ...acc,
18 [`${namespace}/${name}(.*)$`]: `<rootDir>/../../packages/./${name}/src/$1`,
19 }),
20 {},
21 ),
23​
24module.exports = {
25 collectCoverage: true,
26 coverageReporters: ['json', 'lcov', 'text', 'clover', 'text-summary'],
27 testMatch: ['<rootDir>/**/src/**/*.test.[jt]s?(x)'],
28 transform: {
29 '^.+\\.(ts|tsx)$': [
30 'ts-jest',
31 {
32 isolatedModules: true,
33 diagnostics: {
34 exclude: ['**'],
35 },
36 },
37 ],
38 },
39 setupFilesAfterEnv: ['<rootDir>../../jest.setup.js'],
40 clearMocks: true,
41 testEnvironment: 'jsdom',
42 snapshotFormat: {
43 printBasicPrototype: false,
44 },
45 moduleNameMapper,