sh:1:cucumber.js:未找到

时间:2019-01-28 19:02:04

标签: node.js npm cucumber nvm

尝试在此处使用本教程:

https://github.com/lykmapipo/nodejs-cucumber-sample

nvm current的输出是:v10.12.0

npm --version的输出是:6.4.1>

调用npm test后出现以下错误:

> nodejs-cucumber-sample@0.0.1 test /home/gnuc/code/nodejs-cucumber-sample
> cucumber.js

sh: 1: cucumber.js: not found

我不确定为什么会这样。 $PATH包括/home/gnuc/.nvm/versions/node/v10.12.0/bin。而且我已经用过npm install cucumber -gnpm install cucumber

3 个答案:

答案 0 :(得分:0)

确保您的package.json文件包含以下内容:"test": "cucumber-js"

看起来像这样:

{
      "name": "hellocucumber",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "test": **"cucumber-js"**
      },
      "keywords": [],
      "author": "",
      "license": "ISC",
      "devDependencies": {
        "cucumber": "^5.1.0"
      }
    }

答案 1 :(得分:0)

因此,您需要实际调用npm软件包/库。我在package.json中定义了以下内容:

Function FirstMethod
{
    param($number)
    Write-Host "$number - some other things"
    return $number
}

Function ThirdMethod
{
    Write-Host "Second called"
    return 'test'
}

$all = @(
    @{ Name = 'First'; Method = ( FirstMethod 1 ); Description = "First Description";  }
    @{ Name = 'Second'; Description = "Second Description" }
    @{ Name = 'Third'; Method = ( ThirdMethod ); Description = "Third Description" }
)

您还可以在此呼叫中添加一些---标记。

 "scripts": {
    "test": "node ./node_modules/.bin/cucumber-js"
 },

这将运行顶部带有@RegressionTestSuite的所有功能文件

我还有一个带有时间戳的输出/结果文件。

 "scripts": {
    "test": "node ./node_modules/.bin/cucumber-js --tags @RegressionTestSuite"
 },

我希望这会有所帮助。

答案 2 :(得分:0)

node ./node_modules/cucumber/bin/cucumber-js

此命令运行正常。
然后您得到sh:1:cucumber.js:未发现错误意味着首先请注意cumulage.js的路径