2022-12-26 03:52:48 +00:00
|
|
|
import nextJest from 'next/jest';
|
|
|
|
|
|
|
|
const createJestConfig = nextJest({
|
|
|
|
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
|
|
|
|
dir: './',
|
|
|
|
});
|
|
|
|
|
|
|
|
const customClientConfig = {
|
|
|
|
testEnvironment: 'jest-environment-jsdom',
|
|
|
|
setupFilesAfterEnv: ['<rootDir>/tests/client/jest.setup.tsx'],
|
|
|
|
testMatch: ['<rootDir>/src/client/**/*.{spec,test}.{ts,tsx}', '!<rootDir>/src/server/**/*.{spec,test}.{ts,tsx}'],
|
|
|
|
};
|
|
|
|
|
|
|
|
const customServerConfig = {
|
|
|
|
testEnvironment: 'node',
|
|
|
|
testMatch: ['<rootDir>/src/server/**/*.test.ts'],
|
|
|
|
setupFilesAfterEnv: ['<rootDir>/tests/server/jest.setup.ts'],
|
|
|
|
};
|
|
|
|
|
|
|
|
export default async () => {
|
|
|
|
const clientConfig = await createJestConfig(customClientConfig)();
|
|
|
|
const serverConfig = await createJestConfig(customServerConfig)();
|
|
|
|
|
|
|
|
return {
|
2023-07-05 19:24:25 +00:00
|
|
|
randomize: true,
|
2022-12-26 03:52:48 +00:00
|
|
|
verbose: true,
|
|
|
|
collectCoverage: true,
|
|
|
|
collectCoverageFrom: ['src/server/**/*.{ts,tsx}', 'src/client/**/*.{ts,tsx}', '!src/**/mocks/**/*.{ts,tsx}', '!**/*.{spec,test}.{ts,tsx}', '!**/index.{ts,tsx}'],
|
|
|
|
projects: [
|
|
|
|
{
|
|
|
|
displayName: 'client',
|
|
|
|
...clientConfig,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'server',
|
|
|
|
...serverConfig,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
};
|