You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
問題 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 =
Doubling down on local development with Workers: Miniflare meets workerd2022-11-18 Local development gives you a fully-controllable and easy-to-debug testing environment. At the start of this year, we brought this experience to Workers developers by launching Miniflare 2.0: a local Cloudflare Workers simulator. Miniflare 2 came with features like step-through debugging support, detailed console.lo
Features [jest-config] [BREAKING] Add mts and cts to default moduleFileExtensions config (#14369) [jest-config] [BREAKING] Update testMatch and testRegex default option for supporting mjs, cjs, mts, and cts (#14584) [@jest/core] [BREAKING] Group together open handles with the same stack trace (#13417, & #14543) [@jest/core, @jest/test-sequencer] [BREAKING] Exposes globalConfig & contexts to TestSe
You can find the content of this article updated to the most recent version of vue-test-utils and Jest on my book. The module managers we have in the JavaScript community, mainly ES Modules and CommonJS, don't support project-based paths. They only support relative paths for our own modules, and paths for the node_modules folder. When a project grows a bit, it's common to see paths such:
こんにちは、エンジニアのYoheiです。 早速ですが、皆さんはテストコードを書いたことはありますか? テストを書くとなると腰が重くなってしまう方もいるかもしれませんが、実はテストを書くと良いことがたくさんあるんです。 テストについてよくわからない方、これからテストを書き始めるという方はぜひ読んでみてください! 前半は、テストの概要について説明します。 後半は、Javascriptの テスティングフレームワークである Jest を使って実際のコードを例に説明していきます。 まずはテストの概要について簡単に見ていきましょう。 テストとは ※学校でやるテストではありません。 ここでのテストとは、プログラムのテストです。 プログラムのテストとは、実装したプログラムが意図した通りに動いているかを検証するために行うものです。 テストの種類 テストには主に3つの種類が存在し、以下のように分類できます。
この記事の概要 Next.js + TypeScriptのプロジェクトにJestを導入する手順を解説した記事です。 対象読者 Next.jsを触った事がある人 TypeScriptの基礎的な知識がある人 Jestについて基礎的な知識がある人 この記事を書こうと思った動機 最近Next.jsで個人開発を始めました。 Next.jsはReactベースのフレームワークです。 Reactの create-react-app に似たcreate next-appというコマンドがあります。(プロジェクトのテンプレートを自動生成するツールです) ただしReactの create-react-app と違ってテスト実行環境は用意されていません。 そこでJESTを導入する手順を残しておきます。 実行環境 Node.js 14.15.3 Next.js 11.1.2 React 17.0.2 具体的な手順とゴ
In the Jest 26 blog post about a year ago, we announced that after two major releases with few breaking changes, Jest 27 will flip some switches to set better defaults for projects that are new or can migrate smoothly. This gives us the opportunity to remove some packages from the default distribution of Jest 28 and publish them as separately installable and pluggable modules instead. Everyone on
やり方には、ts-jestを使う方法と、babelを使う方法がある。 babelを使うやり方は、https://kinosuke.hatenablog.jp/entry/2020/01/29/115640 と同じアプローチ。preset-envをpreset-typescriptにするだけ。ただし、型チェックはできない。 今回は、型チェックもやってほしいので、ts-jestを使う方法を試してみる。 ライブラリのインストール npm install --save-dev jest ts-jest @types/jest @types/jest jestの型を定義 ts-jest Jest用のTypeScriptプリプロセッサ JestがTypeScriptをトランスパイルできるようになる Jestを設定する # 設定ファイルを作成する npx jest --init ${APP_DIR}/j
Is there a way to make it so that jest always mocks my modules so I don't need to include it in all my jest tests? Currently I have a config file // src/__mocks__/config.js export default { dbConfig: 'TestDBConfiguration' }; // src/config.js export default { dbConfig: ... // Some other stuff }; To run my unit tests I have to use the mocked config.js. Currently in all my unit tests I have to includ
Storybook の Component Story Format 3.0 では新機能として play() 関数が追加されました。 play() 関数は Storybook 上でユーザーのクリックやフォーム入力のようなインタラクションな操作を表現できます。 以前は composeStories() 関数により Storybook 上で作成したストーリーを Jest で再利用する方法を書いたのですが、どうやら Storybook のみで完結してテストを実行できるようですのでこちらを試してみます。 Vite プロジェクトの作成 まずは以下コマンドで Vite プロジェクトを作成します。 $ npm init vite@latest my-vue-app -- --template vue-ts $ cd my-vue-app $ npm install Storybook のインストール 続
Features [jest-circus, jest-snapshot] Add support for snapshot matchers in concurrent tests (#14139) [jest-cli] Include type definitions to generated config files (#14078) [jest-snapshot] Support arrays as property matchers (#14025) [jest-core, jest-circus, jest-reporter, jest-runner] Added support for reporting about start individual test cases using jest-circus (#14174) Fixes [jest-circus] Preve
Jest 29 is here, just a few short months after Jest 28. As mentioned in the Jest 28 blog post, this version contains just a couple of breaking changes, in order to make the upgrade as smooth as possible. The only breaking changes that should be noticeable are: Node versions 12 and 17 are dropped, both of which are EOL The snapshotFormat property is changed to: + snapshotFormat: { + escapeString: f
こんにちは。サービスGの金谷です。 JestにはspyOnという便利なメソッドが用意されています。 Jestオブジェクト · Jest これを使うとJestでのテスト時に指定したメソッドがコールされているかどうかを確認できたりします。 具体的な使い方のイメージは先輩が書かれているこちらの記事が参考になると思います。 jest.spyOn() で Vue.js コンポーネントからのサービス呼び出しをテストする 公式ドキュメントを見ると第一引数にObject、第二引数にメソッド名(文字列)を受け取ると書かれています。 jest.spyOn(object, methodName) では、オブジェクトのメソッドではない、ファイル直下でexportされている関数にはどう使ったらいいの・・・? と思ったので調べてみました。 以下のようなコードを想定します。 helloWorldService.ts e
Upgrading Jest from v27 to v28? This guide aims to help refactoring your configuration and tests. CompatibilityThe supported Node versions are 12.13, 14.15, 16.10 and above. If you plan to use type definitions of Jest (or any of its packages), make sure to install TypeScript version 4.3 or above. Configuration OptionsextraGlobalsThe extraGlobals option was renamed to sandboxInjectedGlobals:
JavaScriptのテストフレームワークであるJestの入門書です。 Jestのインストールから基本的なアサーション、モック化、UIテストからE2EテストやCIツールの導入など実践的な使い方まで紹介しています。Jestはユニットテストに必要な機能をほぼ網羅しているため、これからNode.jsやJavaScriptのテスト書き始める人には最適なテストフレームワークです。ぜひ本書を通じてJestを利用してテストを書くことの手軽さやテストの有用性を知って頂ければ幸いです。 本書では、まだJestを使ったことがない、テストを書いたことがないという方でも、1つずつ試しながら読み進めることができます。 また、サンプルコードも充実しており、本書のコードはすべてGithubのリポジトリからダウンロードすることができます。 ■ 目次 1. はじめに 2. Jestとは? 3. Jestのインストールとはじ
【Prismaとテストシリーズ】jest-prismaでテストケースごとに隔離されたトランザクションで快適にテストできるか試してみた 「前のテストケースで追加されたレコードのせいで他のテストが失敗した」、「自分でレコードのクリーンアップをするのは厳しい」、「いい感じにテストケースごとにDBのトランザクションはる方法がないかな」というモチベーションで試してみました。Rspecで表現すると `use_transactional_fixtures` に該当すると思います。 こんにちは。AWS事業本部モダンアプリケーションコンサルティング部に所属している今泉(@bun76235104)です。 PrismaはTypeScriptでも利用できるORMの一つです。 私もよく利用させていただくのですが、DBが絡むコードのテストの時には以下のようなことを気にしませんか? Docker(コンテナ)を使ってモッ
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く