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?

Cypressをバージョンアップしたら動かなくなった

Posted at

Cypressで自動テストを作成したがなかなか思った通りに動かなかった…という備忘録作業メモです。

原因

テストしたいwebサイトにログインしたあと、他項目で再ログインをするためCookieを保持しておこうと思ったがうまくできていない。

CookieはCypressで提供されているinterface Cookieを使用して情報を保持しようとしていたが、どうやらここで正常にCookie情報が保持されていないようだった。

過去にCypress.Cookieを利用していた際のCypressバージョンは13.7.2、今回試していたバージョンは14.0.1だったため、バージョンを戻してみると正常に動作した。

Cypress.Cookieは使えない?

パッチノートや更新を確認してもinterface Cookieが廃止された、非推奨となった記載は見当たらない。
https://docs.cypress.io/app/references/changelog#14-0-0
https://docs.cypress.io/app/references/migration-guide

というかinterface Cookieはバージョン14でも利用されているsetCookieなどの型継承に使われている。
過去のバージョンをインストールして確認していくと、バージョン13.17.0では利用できた。
バージョン14.0.0では利用できなくなっていたが、その間でのテストの変更点はpackage-lock.jsonのCypressのバージョンのみ。

とりあえず14.0.0以降でのCookieの保持にはgetCookiesetCookieを使うのが一般的なのかも
Cypressのバージョンを更新する際は、意図したとおりのURLにアクセスしログインができているか、Cookieが正常に取得できているか、以前のバージョンとの差異はどこかを確認するようにする。

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?