【トラブル】NightWatch に関するトラブルシューティング

■ はじめに

https://dk521123.hatenablog.com/entry/2021/02/06/220603

等で発生したNightWatch に関するトラブルについて、
まとめておく。

目次

【1】警告「WARN  Local Chrome version is XX, but the installed chromedriver is for version YY」が表示

【1】警告「WARN Local Chrome version is XX, but the installed chromedriver is for version YY」が表示

 テスト実行コマンド「npm run test:e2e」後に
以下の「警告内容」が表示される

警告内容

 WARN  Local Chrome version is 88, but the installed chromedriver is for version 87.
 WARN  There may be incompatibilities between them.
 WARN  Please update your chromedriver dependency to match the Chrome version.

原因

使用しているChromeバージョン(88)と
インストールされているchromedriver のバージョン(version 87)が
一致しなかったため。

対応策

バージョンを合わせてあげればいい。
今回の場合は、Vueプロジェクトを使っているので以下のように対応。

[1] packeage.json を 使用しているChromeバージョン(88)に合うように修正
 => 以下「packeage.json (修正後)」を参照。

[2] コマンド「npm install」を実行
 => 以下のように表示された
~~~~
To address all issues (including breaking changes), run:
  npm audit fix --force
~~~

[3] コマンド「npm audit fix --force」を実行
 => 再度、「npm run test:e2e」実行し、警告が表示されなくなることを確認

packeage.json (修正後)

    "chromedriver": "^88.0.0",

関連記事

Vue + NightWatch で E2Eテスト をする
https://dk521123.hatenablog.com/entry/2021/02/06/220603