influxdata / influxdata/docs-v2
perf(tests): API reference Cypress tests take 7+ minutes due to redundant page visits
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 82
- Forks
- 326
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 82
Description
## Problem
`cypress/e2e/content/api-reference.cy.js` takes 7m08s (428,988ms) to run 121 tests — ~3.5s per test on average. The bottleneck is structural, not infrastructure.
## Root Causes
### 1. `beforeEach` reloads the page for every test (~5.5 min)
121 tests = 121 `cy.visit()` calls. Each `it()` block is wrapped in a `describe` whose `beforeEach` visits the page, but the tests only read DOM state — they never click, type, or mutate anything that would require a fresh page.
Worst offenders by visit count:
- `/influxdb3/core/api/write-data/` — visited **26 times** across 6 describe blocks
- `/influxdb3/enterprise/api/write-data/` — visited **22 times** across 5 describe blocks
- `/influxdb3/core/api/` — visited **10 times** across 3 describe blocks
**Fix**: Move `cy.visit()` from `beforeEach` to `before()` inside each per-page describe. Reduces 121 visits to ~31.
### 2. `cy.intercept('GET', '**')` fires on every subrequest (~30-60s)
8 of 13 `beforeEach` blocks install a `cy.intercept('GET', '**', ...)` handler to disable Kapa fingerprinting. This intercept fires on **every HTTP request** during page load — JS bundles, CSS, fonts, images — not just the HTML document. Each callback inspects `content-type`, buffers the response body, and runs a regex replacement.
At ~25-40 subrequests per page × 93 intercepted visits = ~2,500-3,700 unnecessary callbacks.
**Fix**: Narrow the pattern to the page URL:
```javascript
// Before — fires on every subrequest
cy.intercept('GET', '**', (req) => { ... });
// After — fires only on the HTML document
cy.intercept('GET', page, (req) => { ... });
```
### 3. `skipExternalLinks` env var is set but never honored
`run-e2e-specs.js` passes `env: { skipExternalLinks: true }` to Cypress, but the test never reads `Cypress.env('skipExternalLinks')`. External link tests run unconditionally on all 7 API index pages.
**Fix**: Guard external link tests with the env var or move to a dedicated link-check spec.
### 4. Duplicate page coverage across describe blocks
`/influxdb3/core/api/write-data/` is tested in 6 separate describe blocks (layout, tag pages, download buttons, code samples, client library links, related links) that could be consolidated.
## Expected Improvement
With all fixes: ~7 min → ~1-1.5 min (31 visits × ~2s each + test execution).
## Files
- `cypress/e2e/content/api-reference.cy.js`
- `cypress/support/run-e2e-specs.js` (for `skipExternalLinks` context)
- `cypress.config.js` (timeout settings: 10s command, 30s page load)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with cypress/e2e/content/api-reference.cy.js and inspect its per-page describe blocks, beforeEach hooks, intercepts, and external-link tests. Read cypress/support/run-e2e-specs.js for the skipExternalLinks context and cypress.config.js for timeouts. Done means the API reference tests preserve coverage while reducing redundant visits and completing near the expected 1–1.5 minute range.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cypress, javascript
- Domain
- performance, testing-qa
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100