Add support for inline snapshots tests
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 122k
- Forks
- 37.3k
- Ø Merge
- 4 T. 2 Std.
- Gemergte PRs (30 T.)
- 283
Beschreibung
What is the problem this feature will solve?
Jest inline shapshots are like file-based snapshots but much more casual. I love using them for small snapshots and I think they'd be a great improvement to Node.js. From Jest's docs, they look like:
it('renders correctly', () => {
const tree = renderer
.create(<Link page="https://example.com">Example Site</Link>)
.toJSON();
expect(tree).toMatchInlineSnapshot(`
<a
className="normal"
href="https://example.com"
onMouseEnter={[Function]}
onMouseLeave={[Function]}
>
Example Site
</a>
`);
});
What is the feature you are proposing to solve the problem?
The Node.js version might look like:
test("renders correctly", async ctx => {
const tree = renderer
.create(<Link page="https://example.com">Example Site</Link>)
.toJSON();
ctx.assert.snapshotInline(`
<a
className="normal"
href="https://example.com"
onMouseEnter={[Function]}
onMouseLeave={[Function]}
>
Example Site
</a>
`);
});
What alternatives have you considered?
I use file snapshots or assert.deepEqual().
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie mit der im Issue verlinkten Dokumentation zu Jest inline snapshots und vergleichen Sie sie mit der vorgeschlagenen Node.js-Test-API ctx.assert.snapshotInline. Prüfen Sie die vorhandenen Alternativen file-snapshot und assert.deepEqual; als abgeschlossen gilt die Aufgabe, wenn Node.js den im Beispiel beschriebenen vorgeschlagenen Ablauf für inline-snapshot-Tests unterstützt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, node.js
- Bereich
- testing
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 30/100