0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Cypressにテストデータを用意する(fixtureの使い方)

Posted at

Cypressでテストデータを用意するには

解決すべきイシュー

Integration内のファイルでテストデータを用意するとコードがごちゃごちゃになって気持ち悪い。テストデータを別のディレクトリ内に配置したい。

最初に知っておくべきこと

Cypressにはこのようにデフォルトでfixtureというテストデータ格納用のディレクトリが用意されている。

スクリーンショット 2022-05-12 21.36.12.png

テストデータの用意の仕方

Jsonファイルか.jsファイルにテストデータを用意。
.jsの場合にはmodele exportを忘れないようにする。

fixtureというディレクトリがデフォルトで用意されている。
ここに好きなテストデータを用意できる。
テストデータは.jsonファイルを用意してjson形式で書くか、jsファイルに
スクリーンショット 2022-05-12 21.28.26.png

スクリーンショット 2022-05-12 23.17.33.png

テストデータの読び出し

Integrationファイルの頭でrequire

スクリーンショット 2022-05-12 23.20.46.png

これでIntegration内でテストデータが利用できます

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?