Recommend pretty-format library provided by jest
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 11.8k
- フォーク
- 7.9k
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 11
説明
I was going through the testing recipes and noticed that the documentation recommends a npm module for pretty printing HTML for snapshot: https://reactjs.org/docs/testing-recipes.html#snapshot-testing.
In this example, we render a component and format the rendered HTML with the pretty package, before saving it as an inline snapshot...
The package is this: https://www.npmjs.com/package/pretty. There is another, imo stronger candidate to replace this package, which is pretty-format. Why would this be better? Its part of jest and the example code in the documentation is already using jest. Therefor it would be better to recommend a dependency from a source that the reader is already more likely to be using other dependencies from (which in this case is jest).
You can pretty print HTML with pretty-format like so:
import prettyFormat from 'pretty-format';
const pretty = (dom: HTMLElement): string => {
return prettyFormat(
dom,
{
plugins: [ prettyFormat.plugins.DOMElement ]
}
)
}
...
expect(
pretty(container)
).toMatchInlineSnapshot(); /* ... gets filled automatically by jest ... */
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
テストレシピのドキュメントにある「Snapshot Testing」セクションを開き、現在の pretty package の推奨を Jest の pretty-format package と比較してください。推奨と例を更新して提案された package を使用するようにし、その後、例が Jest の snapshot testing と引き続き整合していること、およびページで pretty が推奨されなくなっていることを確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, react
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 1/5
- 見積もり時間
- 1時間未満
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 45/100