Karmaで「error TS2468: Cannot find global value 'Promise'.」の対象方法
対処したいエラー
https://gyazo.com/803794b78d85ce730fc570948091bea1
code:エラー
26 02 2020 20:23:24.924:ERROR compiler.karma-typescript: src/all.ts(19,9): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your --lib option. 26 02 2020 20:23:24.924:ERROR compiler.karma-typescript: test/index.test.ts(6,38): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your --lib option. 26 02 2020 20:23:24.959:INFO launcher: Launching browsers ChromeHeadless, FirefoxHeadless with concurrency unlimited 26 02 2020 20:23:24.961:INFO launcher: Starting browser ChromeHeadless 26 02 2020 20:23:24.969:INFO launcher: Starting browser FirefoxHeadless HeadlessChrome 80.0.3987 (Mac OS X 10.14.6) ERROR
You need to include some adapter that implements __karma__.start method!
HeadlessChrome 80.0.3987 (Mac OS X 10.14.6): Executed 0 of 0 ERROR (0.108 secs / 0 secs)
Firefox 73.0.0 (Mac OS X 10.14.0) ERROR
You need to include some adapter that implements __karma__.start method!
Firefox 73.0.0 (Mac OS X 10.14.0): Executed 0 of 0 ERROR (0.188 secs / 0 secs)
npm ERR! Test failed. See above for more details.
解決方法
これでいける。
$ npm i -D @types/node
対処法は簡単だが、ここまでいくのにだいぶ大変だった。既存のプロジェクトでうまく行っているものとのdiffを見ながら、少しづつ差分を減らしてはnpm i && npm tをして探して行った。そもそもどの設定ファイルが影響しているがわかっていなかった。まさか@types/nodeだったとのは...。