LoginSignup
0
0

WARNING ... Critical dependency: the request of a dependency is an expression の対処方

Posted at

環境

  • karma - v6.4.2
  • mocha - 10.2.0
  • webpack - 5.88.2

事象

karma start を実行すると、以下の警告が出力される

WARNING in ./node_modules/mocha/lib/mocha.js 336:24-53
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/mocha/browser-entry.js 14:12-34
 @ ./test/index.spec.ts 6:16-32

結論

1. テストコードにあるmochaのインポートを消す

./test/index.spec.js
- import { describe, it } from "mocha";
+ // import { describe, it } from "mocha";

ESLint のチェックに引っかかる場合、次項もおこなう。

2. .eslintrcを変更する

./.esrintrc.js
module.exports = {

  ...

  overrides: [

    ...

    {
      //[test]
      files: ["**/tests/**/*.spec.{j,t}s?(x)"],
      env: { mocha: true },
    },

    ...

  ],
};

参考

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