Consolidate test harness helpers and replace global stdout/stderr patching
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Refactoring
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- nodejs, typescript
- Ambito
- testing
Direzione di ricerca
Start with the duplicated helpers the issue lists: test/es/helpers/bulk-ingest.test.ts, watch.test.ts, scroll-search.test.ts and msearch.test.ts, plus test/factory.test.ts and test/config/text-output.test.ts. Run rg -n 'process\.(stdout|stderr)\.write = ' test to confirm the baseline. Done means one shared capture and transport helper under test/helpers/ that uses t.mock.method, with the grep returning 0 and npm test passing. The helper signatures differ between files, so decide on a shared signature with the maintainers before migrating.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
Tests patch global streams by hand and copy the same harness helpers between files.
- Global stream patching.
rg -n 'process\.(stdout|stderr)\.write = ' testfinds 82 assignments in 19 files (rg -l ... | wc -l). Examples:test/config/text-output.test.ts,test/config/loader.test.ts,test/docs/chat.test.ts:138-158. If a test skips its restore, runner output is lost and later tests see the stub. - Duplicated helpers (
rg -n 'function <name>\b|const <name>\b' test):mockTransport: 4 files (test/es/helpers/{bulk-ingest,scroll-search,watch,msearch}.test.ts)makeDeps: 5 files (the four above plustest/es/handler.test.ts:40)runCommand: 4;captureOutput: 4 in 3 files;captureStdout: 2 (test/factory.test.ts:2059,2364,4188,test/es/search-schema.test.ts:33,test/es/helpers/watch.test.ts:49)makeClient: 4 in 2 files (test/lib/es-client.test.ts,test/lib/kibana-client.test.ts)mkdtemp: 24 files.ELASTIC_CLI_CONFIG_FILEused: 9 files.
The copies have different signatures:
bulk-ingest.test.ts:18mockTransport(responses: Array<{ errors: boolean, items: ... }>)vswatch.test.ts:32mockTransport(responses: MockResponse[])factory.test.ts:2059captureOutput(fn: () => Promise<void>)vswatch.test.ts:49captureOutput()(takes no arguments and returns a sink)
Note: test/docs/chat.test.ts patches process.stderr.write on purpose. The test checks that the chat loop never writes to the real stderr (assert.deepEqual(realWrites, [])). It does not show a bypass in src/docs/*.
Proposal
Add test/helpers/{capture,transport,tmp-config}.ts. capture(t) uses t.mock.method(process.stdout, 'write', ...), which node:test restores automatically. Migrate in small PRs: the four test/es/helpers tests first, then factory.test.ts. Keep the chat.test.ts guard, but switch it to t.mock.method.
Acceptance criteria
-
rg 'process\.(stdout|stderr)\.write = ' testreturns 0 matches - Only one
mockTransport/captureOutputdefinition exists, intest/helpers/ - Temporary config setup (
mkdtemp+ELASTIC_CLI_CONFIG_FILE) goes through one helper with automatic cleanup -
npm testpasses on all supported Node versions
Related: #733 (DI for _test* seams).
authored by Pi Coding Agent (Claude Opus 5.5)
- Lingua principale
- TypeScript
- Stelle
- 47
- Fork
- 27
- Merge medio
- 2g 6h
- PR unite (30g)
- 52
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di elastic/cli
-
feat: ship skills/elastic/SKILL.md for agent invocationForse già presa @onatozmenn l’ha presa 15 giorni fa. Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
elastic/cli#628 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
elastic/cli#617 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 Mezza giornata Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 20/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
db-ux-design-system/core-web#8461 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Cannot run an integration on windows when power shell is selected as the default profile terminalApertaPriority/Blocker Type/Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
wso2/product-integrator#2767 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
severity:low
Difficoltà 1/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno