我正在使用脚本
// src/test-index.js
const context = require.context('./src', true, /-test\.js$/)
context.keys().forEach(context)
而且我一直遇到错误
> NODE_ENV=test karma start --single-run --no-auto-watch
...
ERROR [karma]: { Error: no such file or directory
at MemoryFileSystem.readFileSync (PROJECT_ROOT/node_modules/memory-fs/lib/MemoryFileSystem.js:107:10)
at MemoryFileSystem.readFile (PROJECT_ROOT/node_modules/memory-fs/lib/MemoryFileSystem.js:297:21)
at doRead (PROJECT_ROOT/node_modules/karma-webpack/index.js:156:26)
at Plugin.readFile (PROJECT_ROOT/node_modules/karma-webpack/index.js:160:3)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
code: 'ENOENT',
errno: 34,
message: 'no such file or directory',
path: '/_karma_webpack_/test-index.js' }
Error: no such file or directory
at MemoryFileSystem.readFileSync (PROJECT_ROOT/node_modules/memory-fs/lib/MemoryFileSystem.js:107:10)
at MemoryFileSystem.readFile (PROJECT_ROOT/node_modules/memory-fs/lib/MemoryFileSystem.js:297:21)
at doRead (PROJECT_ROOT/node_modules/karma-webpack/index.js:156:26)
at Plugin.readFile (PROJECT_ROOT/node_modules/karma-webpack/index.js:160:3)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
这是我的要点karma.conf.js
的链接和webpack.config.js
。我忽略了其他文件,因为这些(加上test-index.js
上面的)是当前进程中涉及的唯一文件。
节点 v6.2.0,npm v3.8.9(通过 nvm 安装)。所有依赖项都是在过去几个小时内安装的,所以我使用的是最新版本。
关于什么可能是错的或我还能尝试什么的任何想法?