Files
calendar/apps/api/v2/jest-e2e.ts
T
Anik Dhabal BabuGitHubDevin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
17224d9df3 ci: reduce e2e-api-v2 test overhead with caching and Jest optimizations (#26331)
* perf: increase E2E test shards from 4 to 6 for faster CI

Increase the number of parallel E2E test shards from 4 to 6 to reduce
overall CI wall-clock time. Each shard runs on a separate 4-vCPU runner
with 4 workers, so adding more shards increases total parallelism.

This should reduce E2E test time from ~3 minutes per shard to ~2 minutes
per shard by distributing tests across more parallel jobs.

Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>

* update

* fix

* update

* readd

* final update

* fix flake

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2025-12-31 10:19:09 -03:00

60 lines
1.6 KiB
TypeScript

import type { Config } from "jest";
// Detect if sharding is being used by checking for --shard flag
const isSharding = process.argv.some((arg) => arg.includes("--shard"));
// For Jest e2e, we reduce parallelism when sharding in CI to improve test isolation
// since tests share database state and can interfere with each other
const getMaxWorkers = () => {
if (process.env.CI && isSharding) {
// In CI with sharding: reduce workers to improve test isolation
// Sharding already provides parallelism across shards (4 parallel jobs)
return 4;
}
// Local development or non-sharded: use more workers (similar to Playwright)
return 8;
};
const maxWorkers = getMaxWorkers();
const config: Config = {
moduleFileExtensions: ["js", "json", "ts"],
rootDir: ".",
moduleNameMapper: {
"@/(.*)": "<rootDir>/src/$1",
"test/(.*)": "<rootDir>/test/$1",
},
testEnvironment: "node",
testRegex: ".e2e-spec.ts$",
transform: {
"^.+\\.ts$": [
"ts-jest",
process.env.CI
? {
isolatedModules: true,
diagnostics: false,
}
: {},
],
},
setupFiles: ["<rootDir>/test/setEnvVars.ts", "jest-date-mock"],
setupFilesAfterEnv: ["<rootDir>/test/jest.setup-e2e.ts"],
reporters: [
"default",
"jest-summarizing-reporter",
[
"jest-junit",
{
outputDirectory: "./test-results",
outputName: "junit.xml",
},
],
],
workerIdleMemoryLimit: "512MB",
maxWorkers,
testPathIgnorePatterns: ["/dist/", "/node_modules/"],
transformIgnorePatterns: ["/dist/", "/node_modules/"],
};
export default config;