gpt4 book ai didi

javascript - 开 Jest 按特定路径运行测试

转载 作者:行者123 更新时间:2023-12-05 00:37:48 30 4
gpt4 key购买 nike

目前我正在使用标准的 testRegex 逻辑来运行我的测试

  "jest": {
"moduleFileExtensions": [
"ts",
"js"
],
"transform": {
"^.+\\.ts?$": "<rootDir>/node_modules/ts-jest/preprocessor.js",
"^.+\\.js?$": "babel-jest"
},
"testRegex": "/tests/.*\\.(ts|js)$"
}

但我想使用特定路径拆分它们
test-client   "testRegex": "/tests/client/.*\\.(ts|js)$"
test-server "testRegex": "/tests/server/.*\\.(ts|js)$"

我看到有一个选项--runTestsByPath。但我找不到任何例子

欢迎反馈

更新

我试图添加脚本
"test-client": "jest   --runTestsByPath \"tests/client/\""

带有测试文件:tests/client/test.spec.js

但出现错误:
$ jest   --runTestsByPath "tests/client/"
No tests found
No files found in /Users/../myapp.
Make sure Jest's configuration does not exclude this directory.

最佳答案

我使用以下命令并且工作:

jest "/client"
您可以在此处查看 Jest 文档: https://jestjs.io/docs/en/22.x/cli

关于javascript - 开 Jest 按特定路径运行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54005053/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com