Skip to content

[test optimization] Improve cypress testing time#7814

Merged
juan-fernandez merged 5 commits intomasterfrom
juan-fernandez/improve-cypress-testing-time
Mar 18, 2026
Merged

[test optimization] Improve cypress testing time#7814
juan-fernandez merged 5 commits intomasterfrom
juan-fernandez/improve-cypress-testing-time

Conversation

@juan-fernandez
Copy link
Copy Markdown
Collaborator

What does this PR do?

Reduces Cypress integration test wall-clock time by eliminating redundant Cypress process spawns and unnecessary test execution. Each Cypress spawn costs ~10-20s (browser launch, module loading), so removing them has a significant impact.

Changes:

  1. Merge duplicate ATR tests: Combined "retries flaky tests in the correct order" into "retries flaky tests" — both spawned identical Cypress processes with the same settings and spec file. The order assertions now run in the same callback.

  2. Merge duplicate EFD tests: Combined "sets TEST_HAS_FAILED_ALL_RETRIES when all EFD attempts fail" into "retries new tests in the correct order" — identical settings, known tests, and spec file.

  3. Merge "catches errors in hooks" into "can run and report tests": Both ran all .cy.js specs with no SPEC_PATTERN. Now a single Cypress run verifies both reporting correctness and hook error handling. Added SPEC_PATTERN to exclude spec-source-line-invocation.cy.js which neither test needed.

  4. Merge "after:spec" into "after:run" test: Both had identical assertions (4 suites, 9 tests) and only differed by which custom hook env var was set. The hooks are independent, so testing both simultaneously is equivalent.

  5. Add SPEC_PATTERN to "user_provided_service" test: Was running all 10 .cy.js tests but only needed one spec to verify the DD_TEST_IS_USER_PROVIDED_SERVICE tag.

Estimated savings: ~75-85s per version × module-type matrix combination.

Motivation

The Cypress integration tests run for every version × module-type combination ([email protected]/10.2.0/14.5.4/latest × commonJS/esm). Several tests were spawning separate Cypress processes with identical configurations, and others were running more Cypress specs than their assertions required. Since Cypress startup is the dominant cost per test (~10-20s), eliminating redundant spawns is the most effective optimization available.

@juan-fernandez juan-fernandez marked this pull request as ready for review March 18, 2026 08:52
@juan-fernandez juan-fernandez requested a review from a team as a code owner March 18, 2026 08:52
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 18, 2026

Overall package size

Self size: 4.97 MB
Deduped: 5.82 MB
No deduping: 5.82 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.0.0 | 81.15 kB | 815.98 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.36%. Comparing base (f20430c) to head (c30c1ba).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7814      +/-   ##
==========================================
- Coverage   80.45%   80.36%   -0.09%     
==========================================
  Files         748      747       -1     
  Lines       32411    32327      -84     
==========================================
- Hits        26075    25981      -94     
- Misses       6336     6346      +10     
Flag Coverage Δ
aiguard-macos 39.10% <ø> (-0.10%) ⬇️
aiguard-ubuntu 39.22% <ø> (-0.10%) ⬇️
aiguard-windows 38.95% <ø> (-0.10%) ⬇️
apm-capabilities-tracing-macos 48.91% <ø> (ø)
apm-capabilities-tracing-ubuntu 48.94% <ø> (ø)
apm-capabilities-tracing-windows 48.68% <ø> (ø)
apm-integrations-child-process 38.41% <ø> (-0.10%) ⬇️
apm-integrations-couchbase-18 37.33% <ø> (-0.10%) ⬇️
apm-integrations-couchbase-eol 37.79% <ø> (-0.10%) ⬇️
apm-integrations-oracledb 37.63% <ø> (-0.10%) ⬇️
appsec-express 55.19% <ø> (-0.07%) ⬇️
appsec-fastify 51.54% <ø> (-0.07%) ⬇️
appsec-graphql 51.74% <ø> (-0.06%) ⬇️
appsec-kafka 44.29% <ø> (-0.08%) ⬇️
appsec-ldapjs 43.92% <ø> (-0.08%) ⬇️
appsec-lodash 43.55% <ø> (-0.08%) ⬇️
appsec-macos 58.12% <ø> (-0.07%) ⬇️
appsec-mongodb-core 48.71% <ø> (-0.08%) ⬇️
appsec-mongoose 49.37% <ø> (-0.08%) ⬇️
appsec-mysql 50.79% <ø> (-0.07%) ⬇️
appsec-node-serialize 43.10% <ø> (-0.08%) ⬇️
appsec-passport 47.55% <ø> (-0.09%) ⬇️
appsec-postgres 50.52% <ø> (-0.07%) ⬇️
appsec-sourcing 42.53% <ø> (-0.08%) ⬇️
appsec-template 43.27% <ø> (-0.08%) ⬇️
appsec-ubuntu 58.20% <ø> (-0.07%) ⬇️
appsec-windows 57.96% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-bluebird 32.24% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-body-parser 40.42% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-child_process 37.73% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-cookie-parser 34.22% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-express 34.54% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-express-mongo-sanitize 34.35% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-express-session 40.06% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-fs 31.86% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-generic-pool 29.52% <ø> (ø)
instrumentations-instrumentation-http 39.70% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-knex 32.25% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-mongoose 33.37% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-multer 40.17% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-mysql2 38.18% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-passport 43.96% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-passport-http 43.64% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-passport-local 44.17% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-pg 37.62% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-promise 32.17% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-promise-js 32.18% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-q 32.22% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-url 32.15% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-when 32.19% <ø> (-0.10%) ⬇️
llmobs-ai 42.16% <ø> (-0.09%) ⬇️
llmobs-anthropic 40.20% <ø> (-0.09%) ⬇️
llmobs-bedrock 39.16% <ø> (-0.08%) ⬇️
llmobs-google-genai 39.70% <ø> (-0.09%) ⬇️
llmobs-langchain 39.95% <ø> (-0.08%) ⬇️
llmobs-openai 43.87% <ø> (-0.09%) ⬇️
llmobs-vertex-ai 39.95% <ø> (-0.09%) ⬇️
platform-core 31.47% <ø> (ø)
platform-esbuild 34.42% <ø> (ø)
platform-instrumentations-misc 48.41% <ø> (ø)
platform-shimmer 37.56% <ø> (ø)
platform-unit-guardrails 32.89% <ø> (ø)
plugins-azure-durable-functions 25.74% <ø> (ø)
plugins-azure-event-hubs 25.90% <ø> (ø)
plugins-azure-service-bus 25.26% <ø> (ø)
plugins-bullmq 44.09% <ø> (-0.10%) ⬇️
plugins-cassandra 37.81% <ø> (+0.04%) ⬆️
plugins-cookie 26.96% <ø> (ø)
plugins-cookie-parser 26.75% <ø> (ø)
plugins-crypto 26.73% <ø> (ø)
plugins-dd-trace-api 38.21% <ø> (-0.10%) ⬇️
plugins-express-mongo-sanitize 26.89% <ø> (ø)
plugins-express-session 26.70% <ø> (ø)
plugins-fastify 42.14% <ø> (-0.09%) ⬇️
plugins-fetch 38.23% <ø> (-0.09%) ⬇️
plugins-fs 38.51% <ø> (-0.10%) ⬇️
plugins-generic-pool 25.94% <ø> (ø)
plugins-google-cloud-pubsub 45.35% <ø> (-0.09%) ⬇️
plugins-grpc 40.81% <ø> (-0.09%) ⬇️
plugins-handlebars 26.94% <ø> (ø)
plugins-hapi 40.06% <ø> (-0.10%) ⬇️
plugins-hono 40.31% <ø> (-0.10%) ⬇️
plugins-ioredis 38.32% <ø> (-0.10%) ⬇️
plugins-knex 26.57% <ø> (ø)
plugins-langgraph 38.36% <ø> (-0.10%) ⬇️
plugins-ldapjs 24.43% <ø> (ø)
plugins-light-my-request 26.30% <ø> (ø)
plugins-limitd-client 32.52% <ø> (-0.10%) ⬇️
plugins-lodash 26.03% <ø> (ø)
plugins-mariadb 39.36% <ø> (-0.10%) ⬇️
plugins-memcached 38.04% <ø> (-0.10%) ⬇️
plugins-microgateway-core 39.12% <ø> (-0.10%) ⬇️
plugins-moleculer 40.42% <ø> (-0.09%) ⬇️
plugins-mongodb 39.06% <ø> (-0.10%) ⬇️
plugins-mongodb-core 38.90% <ø> (-0.10%) ⬇️
plugins-mongoose 38.75% <ø> (-0.10%) ⬇️
plugins-multer 26.70% <ø> (ø)
plugins-mysql 39.06% <ø> (-0.10%) ⬇️
plugins-mysql2 39.16% <ø> (-0.10%) ⬇️
plugins-node-serialize 27.00% <ø> (ø)
plugins-opensearch 37.50% <ø> (-0.10%) ⬇️
plugins-passport-http 26.76% <ø> (ø)
plugins-postgres 35.49% <ø> (-0.09%) ⬇️
plugins-process 26.73% <ø> (ø)
plugins-pug 26.96% <ø> (ø)
plugins-redis 38.78% <ø> (-0.10%) ⬇️
plugins-router 42.87% <ø> (-0.10%) ⬇️
plugins-sequelize 25.55% <ø> (ø)
plugins-test-and-upstream-amqp10 38.39% <ø> (+0.04%) ⬆️
plugins-test-and-upstream-amqplib 43.76% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-apollo 39.02% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-avsc 38.52% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-bunyan 33.78% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-connect 40.71% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-graphql 40.00% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-koa ?
plugins-test-and-upstream-protobufjs 38.74% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-rhea 43.94% <ø> (-0.10%) ⬇️
plugins-undici 39.00% <ø> (-0.09%) ⬇️
plugins-url 26.73% <ø> (ø)
plugins-valkey 37.98% <ø> (-0.10%) ⬇️
plugins-vm 26.73% <ø> (ø)
plugins-winston 33.97% <ø> (-0.10%) ⬇️
plugins-ws 41.76% <ø> (-0.10%) ⬇️
profiling-macos 40.46% <ø> (-0.10%) ⬇️
profiling-ubuntu 41.00% <ø> (-0.10%) ⬇️
profiling-windows 41.75% <ø> (-0.10%) ⬇️
serverless-azure-functions-client 25.62% <ø> (ø)
serverless-azure-functions-eventhubs 25.62% <ø> (ø)
serverless-azure-functions-servicebus 25.62% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

anmarchenko
anmarchenko previously approved these changes Mar 18, 2026
@datadog-datadog-prod-us1

This comment has been minimized.

@pr-commenter
Copy link
Copy Markdown

pr-commenter bot commented Mar 18, 2026

Benchmarks

Benchmark execution time: 2026-03-18 14:47:36

Comparing candidate commit c30c1ba in PR branch juan-fernandez/improve-cypress-testing-time with baseline commit f20430c in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 230 metrics, 30 unstable metrics.

Copy link
Copy Markdown
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, reducing the runtime is always great!

Copy link
Copy Markdown
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code wise LGTM. I did not check that the tests still match all cases.

@juan-fernandez juan-fernandez merged commit ad01950 into master Mar 18, 2026
787 of 788 checks passed
@juan-fernandez juan-fernandez deleted the juan-fernandez/improve-cypress-testing-time branch March 18, 2026 15:26
@dd-octo-sts dd-octo-sts bot mentioned this pull request Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants