node.js - 找不到磁带测试目录的 Node js 模块

标签 node.js testing npm tap

我有以下结构:

src/examples/test_file.js
src/test/example.test.js

package.json:

  "scripts": {
    "test": "node ./test/*.test.js"
  },

我通过 npm install tape --save 安装了磁带

我运行 npm test 并得到:

> node ./test/*.test.js

module.js:328
    throw err;
    ^

Error: Cannot find module 'c:\src\test\*.test.js'
    at Function.Module._resolveFilename (module.js:326:15)
    at Function.Module._load (module.js:277:25)
    at Function.Module.runMain (module.js:430:10)
    at startup (node.js:141:18)
    at node.js:1003:3
npm ERR! Test failed.  See above for more details.

据此:https://ci.testling.com/guide/tape

对整个目录的测试应该只适用于 Node 包的全局安装。如何在不全局安装磁带的情况下使上述功能正常工作?

我正在使用 Node 5.4 和 Windows 10

编辑:

这对我来说在 Mac 上运行良好,在 linux 构建服务器上运行良好。我假设它的窗口相关

最佳答案

  "scripts": {
       "test": "tape ./test/*.test.js"
     },

尝试使用对“磁带”的调用而不是“Node ”来更新您的脚本语句 npm 将在 ./node_moduels/.bin/tape 的本地安装中找到磁带 无需通过 Node 发送

关于node.js - 找不到磁带测试目录的 Node js 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35261114/

相关文章:

node.js - Nest.js - process.env.npm_package_description 未返回正确的值

node.js - 尝试使用 npm 安装 react-native-cli 时出现未满足的依赖关系错误

node.js - 如何从 Controller JSON 返回的实体字段中排除。 NestJS + Typeorm

Node.js FS 模块启动问题

node.js - 无法通过 npm 自动安装类名包(在 package.json 中定义)

testing - 在单元测试中使用依赖注入(inject)对象是个坏主意吗?

testing - 如何使用 arquillian 进行具有多个 maven 模块的集成测试

node.js - Angular Universal 与 api 内部快速调用

javascript - 在 node.js 的 HTTP GET 中设置 URL 参数的默认值

angularjs - 等待 Protractor 与页面同步时出错 : "[ng:test] no injector found for element argument to getTestability