Allow simpler tests for error.code
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript
- Ambito
- testing-qa
Direzione di ricerca
Inizia individuando i punti di ingresso delle asserzioni throw() e reject() e il comportamento esistente di contain(). Aggiungi la copertura dei test per un messaggio opzionale e per l’oggetto delle proprietà dell’errore proposto, incluso l’esempio ERR_INVALID_ARG_TYPE, e conferma che entrambe le asserzioni mantengano il comportamento attuale.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Support plan
- is this issue currently blocking your project? (yes/no): no
- is this issue affecting a production system? (yes/no): no
Context
- node version: any
- module version: 8.0.3
- environment (e.g. node, browser, native): node
- used with (e.g. hapi application, another framework, standalone, ...):
- any other relevant information:
What problem are you trying to solve?
To test for the .code property attached to node errors (instead of .message) that are not fixed).
Currently I have to do this manually, eg. for throw():
const Code = require('code');
const expect = Code.expect;
const err = expect(() => process.chdir(42)).to.throw(TypeError);
expect(err).to.contain({ code: 'ERR_INVALID_ARG_TYPE' });
// or as one-liner
expect(expect(() => process.chdir(42)).to.throw(TypeError)).to.contain({ code: 'ERR_INVALID_ARG_TYPE' });
Do you have a new or modified API suggestion to solve the problem?
Add a third has parameter to throw() and reject(), which takes an object which is passed to a contain() test. Also make the message optional (works since it uses a string and type must be instanceof Error). Eg.
expect(() => process.chdir(42)).to.throw(TypeError, { code: 'ERR_INVALID_ARG_TYPE' });
- Lingua principale
- JavaScript
- Stelle
- 231
- Fork
- 75
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
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 hapijs/code
-
Incorrect prototype checkApertasupport
Difficoltà 3/5 1-2 giorni Idoneità per principianti 38/100
-
pass parameter to throwApertafeature
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
Issue simili
-
bug(sight): the dashboard's text truncations split surrogate pairs and show broken charactersApertacomponent:sight
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
agentic-os-org/ANOLISA#6738 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug Durable Agents Observability (AI Telemetry) status: needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
mastra-ai/mastra#26470 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
feature/cohorts feature/feature-flags team/feature-flags
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
documentation good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Orbit-xyz/orbit-docs#11 ·
-
area/build area/tech debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 2 giorni