Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

2.7 KB
Raw Blame
const nextJest = require('next/jest');

const createJestConfig = nextJest({
  dir: './',
});

const config = {
  coverageProvider: 'v8',
  testEnvironment: 'jsdom',
  setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
  moduleNameMapper: {
    '^@/(.*)$': '<rootDir>/src/$1',
    // OpenPlait packages are ESM-only and expose their entry points through
    // package export maps. Resolve them explicitly so Jest's CommonJS resolver
    // can hand the files to Next's transformer.
    '^@openplait/([^/]+)$': '<rootDir>/node_modules/@openplait/$1/dist/src/index.js',
  },
  transformIgnorePatterns: [
    '/node_modules/(?!(?:@openplait)/)',
  ],
  collectCoverageFrom: [
    'src/**/*.{ts,tsx}',
    '!src/**/*.d.ts',
    '!src/app/**',
    '!src/instrumentation.ts',
    // UI components are not unit-testable without full rendering setup
    '!src/components/**',
    // ClickHouse connection pool setup
    '!src/clickhouse/**',
    '!src/lib/platform/clickhouse/**',
    // Complex AI provider adapters and OpenGround internals
    '!src/lib/platform/openground/**',
    '!src/lib/platform/openground-clickhouse/**',
    '!src/lib/platform/manage-dashboard/**',
    // Branch-dense SQL/query builders and AI chat surfaces — still have
    // focused unit tests, but v8 branch coverage is dominated by template
    // string paths rather than meaningful control flow.
    '!src/lib/platform/chat/tools.ts',
    '!src/lib/platform/chat/improvement.ts',
    '!src/lib/platform/chat/usage.ts',
    '!src/lib/platform/coding-agents/queries.ts',
    '!src/lib/platform/agents/materialize.ts',
    '!src/lib/platform/agents/snapshot.ts',
    '!src/lib/platform/agents/aggregate-graph.ts',
    '!src/lib/platform/agents/observability-view.ts',
    '!src/lib/platform/evaluation/analytics.ts',
    '!src/lib/platform/graph-transform.ts',
    '!src/lib/platform/request/index.ts',
    '!src/helpers/client/organisation.ts',
    // DB clients/singletons
    '!src/lib/prisma.ts',
    '!src/lib/posthog.ts',
    // TypeScript type definitions only
    '!src/types/**',
    // Type-only exports (no runtime code to cover)
    '!src/middleware/middlewareFactory.ts',
    '!src/constants/dbConfig.ts',
    '!src/constants/prompts.ts',
    '!src/constants/sidebar.tsx',
    // Complex OS-level operations (cron file management, child process spawning)
    '!src/helpers/server/cron.ts',
    // NextAuth session internals (requires full framework context)
    '!src/lib/session.ts',
    // Store initialization (individual slices are tested in their own files)
    '!src/store/index.ts',
  ],
  testMatch: [
    '**/__tests__/**/*.{ts,tsx}',
    '**/*.test.{ts,tsx}',
  ],
  testPathIgnorePatterns: [
    '/node_modules/',
    '/.next/',
  ],
};

module.exports = createJestConfig(config);