首页 > 解决方案 > “Cypress Run”的路径问题

问题描述

我在 Cypress 方面取得了不错的进展,但在尝试调用单个 Spec 时有点卡住了。

中的行package.json看起来像:

  "cypress:runST": "cypress run --spec'/cypress/integration/02_DBM_H1_ST_spec.js'",

我从npm run cypress:runST...错误开始!

即使我尝试将其运行为:

`npm run cypress run --spec '/cypress/integration/02_DBM_H1_ST_spec.js'

我仍然收到错误:

Can't run because no spec files were found.

We searched for any files matching this glob pattern:

'\cypress\integration\02_DBM_H1_ST_spec.js'    

并来自 NPM 日志:

10 silly lifecycle cypress_research@1.0.0~cypress:runST: Args: [ '/d /s /c',
10 silly lifecycle   'cypress run --spec \'/cypress/integration/02_DBM_H1_ST_spec.js\'' ]
11 silly lifecycle cypress_research@1.0.0~cypress:runST: Returned: code: 1  signal: null
12 info lifecycle cypress_research@1.0.0~cypress:runST: Failed to exec cypress:runST script

我有一种感觉,这是命令中的语法,但如果是这种情况,它会再次运行“裸”......但我得到了同样的错误。不知道 '\' afer spec 和之后的 .js 来自哪里。

请问有什么想法吗?谢谢

标签: npmcypress

解决方案


假设 package.json 与 cypress 文件夹处于同一级别,这应该可以工作

"cypress:runST": "cypress run --spec cypress/integration/02_DBM_H1_ST_spec.js",

推荐阅读