nodejs / nodejs/node

Add support for inline snapshots tests

オープン
#59,231 コメント 9 件 リアクション 3 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

feature request never-stale
主要言語
JavaScript
スター
122k
フォーク
37.3k
平均マージ
4日 2時間
マージ済み PR(30日)
283

説明

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().

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Issue にリンクされている Jest inline snapshots のドキュメントから始め、提案されている Node.js のテスト API、ctx.assert.snapshotInline と比較してください。既存の file-snapshot と assert.deepEqual の代替案を確認してください。完了条件は、例で説明されている提案済みの inline-snapshot テストフローを Node.js がサポートすることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, node.js
領域
testing
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。