Allow simpler tests for error.code
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- javascript
- Bereich
- testing-qa
Rechercherichtung
Beginne damit, die Assertion-Einstiegspunkte throw() und reject() sowie das vorhandene Verhalten von contain() zu finden. Füge Testabdeckung für eine optionale Nachricht und das vorgeschlagene Fehler-Eigenschaftenobjekt einschließlich des ERR_INVALID_ARG_TYPE-Beispiels hinzu und bestätige, dass beide Assertions ihr aktuelles Verhalten beibehalten.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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' });
- Vorherrschende Sprache
- JavaScript
- Sterne
- 231
- Forks
- 75
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus hapijs/code
-
support
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 38/100
-
pass parameter to throwOffenfeature
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 30/100
Ähnliche Issues
-
documentation good first issue help wanted
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug release:v5.56
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
Jason-Vaughan/TangleClaw#2270 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
style-dictionary/style-dictionary#1773 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
SignalK/signalk-server#3143 ·
Maintainer antworten meist innerhalb von 1 Tag