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

jest.config.ts

38 lines1013 Bytes

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 projects: packages.map((d) => ({
28 displayName: d,
29 clearMocks: true,
30 testEnvironment: 'jsdom',
31 testMatch: [`<rootDir>/packages/${d}/**/*.test.[jt]s?(x)`],
32 setupFilesAfterEnv: [`<rootDir>/jest.setup.js`],
33 snapshotFormat: {
34 printBasicPrototype: false,
35 },
36 moduleNameMapper,
37 })),