参考動画
テスト (Cypress)
参考動画の3:25辺りから~
Web UI の自動テストツール Cypress を使った自動テスト、end to end test が実行できるようです。
まず、サーバーをコマンドmvnw
で立ち上げておきます。
その後、別のコンソールを開いて、npm run e2e
を実行します。
自動でブラウザが立ち上がり、テストが実行されます。
画面が高速で目まぐるしく動いて、見てたら疲れます(笑)
src\test\javascript\cypress\integration
以下のフォルダに入っている*.spec.ts
ファイルがテストで実行される対象となっています。
エラーになる場合
動画ではnpm run e2e
を実行すると、特にエラーもなく、すんなりうまくいっているみたいですが、私がやるとエラーになりました(笑)
You passed the --record flag but this project has not been setup to record.
This project is missing the 'projectId' inside of 'cypress.json'.
We cannot uniquely identify this project without this id.
You need to setup this project to record. This will generate a unique 'projectId'.
Alternatively if you omit the --record flag this project will run without recording.
調べると、同じエラーに遭遇している人がいるみたいで汗・・・
ファイルpackage.json
の中を以下のように変えると、動作しました。
変更前
"e2e:cypress": "cypress run --browser chrome --record ${CYPRESS_ENABLE_RECORD:-false}",
変更後
"e2e:cypress": "cypress run --browser chrome --record false",
今回のコード