4年ほど前に作ったAWS Lambdaプロジェクトがありました。 もろもろ更新しようとAWS SAMでプロジェクトを作り直したところ、テストライブラリとして Jest が入っていました。 移行する必要があるのか? と言われると、ないですけれど、 趣味なのでやってみます。 テストファイルの場所を移動する テスト対象ファイルとテストファイルを同一ディレクトリに置いていました。
もう駄目だ。ついに React 以外のプロジェクトでも Jest 一択になってしまった。 もともと自分の選択するテストツールは、むかしは jasmine、いまは mocha + chai(ときどき power-assert) をベースに周辺ツールと連携させていて、React を使うようになってしばらくして Jest を入れるようになった。ここ5年くらいのフロントエンド界隈では標準の一種だと思う。 それがどうしてこんなに Jest びいきになったのか。 その1. 楽 とにかく楽だからだ。 Jest の売りはオール・イン・ワンとゼロ・コンフィグというだけあって、構築がとりわけ楽。 1パッケージ入れるだけでざっと以下の機能が使えるようになる。 テストランナー(mocha, jasmine 1) アサーション(chai, jasmine) モック(sinon, testdouble) カバレッジ(
問題 jest + typescript で、eslintが以下のエラーを出力した。 'describe' is not defined. eslint(no-undef) typescriptだと @types/jest を入れろと言われるが、eslint ではそれだけではダメだった。 解決策 eslint-plugin-jest を入れる必要があった。 www.npmjs.com READMEにある通り、以下のようにeslintrc.jsに追記する。 module.exports = { env: { ... "jest/globals": true, }, ... plugins: [ ... "jest", ], ... 結果 'describe' is not defined. は言われなくなった。 参考 eslintrc.js を載せておく。 module.exports =
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く