reactjs - Makefile 命令在子文件夹中运行 react 测试套件

标签 reactjs bash testing makefile

我正在尝试创建一个 Makefile 来运行我的 React 应用程序的测试套件。在根文件夹中,React 应用程序位于 frontend/

我可以用什么make命令来实现这个?我尝试了以下但没有运气:

test-frontend:
    cd ./frontend/
    npm test

test-frontend:
    npm test ./frontend/

test-frontend:
    cd ./frontend/
    npm run-script test

这是我得到的错误:

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /path/to/dir/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/path/to/dir/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     /$HOME/.npm/_logs/2019-10-24T02_23_23_195Z-debug.log
make: *** [test-frontend] Error 254

最佳答案

评论回答了我的问题。答案是:

test-frontend:
    cd ./frontend/ && npm run-script test

或者如果您想使用单独的行以提高可读性:

test-frontend:
    cd ./frontend/ && \
    npm run-script test

关于reactjs - Makefile 命令在子文件夹中运行 react 测试套件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58532803/

相关文章:

python - 在 Python 中对整个应用程序进行回归测试

ruby-on-rails - 基本的 React 元素在带有 webpack 的 Rails 5.1 中不显示

reactjs - 与react.js中的ng-if等效的是什么?

javascript - 我应该如何为以下对象正确使用 setState

linux - 在 Linux 中使用 $ 符号访问每一行

linux - bash 获取硬件脚本输出到 .csv 文件

javascript - 在 react 中一次只有一种形式工作

bash - 映射SSL/TLS密码套件及其等效的OpenSSL

testing - 如何在 Microsoft 测试管理器 (Microsoft Team Foundation Server TFS) 上创建错误并将其链接到测试结果的特定迭代

java - 无法通过 jenkins 上的 chrome webdriver 启动 chrome,因为它在我的本地计算机上运行良好