CucumberJS 脚本错误
CucumberJS script errors
我是 cucumber
的新手,所以我不知道我的问题是由于缺乏理解引起的,还是实际上是脚本错误(我认为不太可能)。所以,我只是将正在发生的事情联系起来。通常,当我 运行 cucumber
时,我会得到 feature/scenario 输出,但脚本稍后会在执行过程中抛出错误。我了解到这可能是由我的 feature
或 steps_definition
文件中的错误引起的,但我不知道要查找什么。
我已将软件包安装为依赖项
"dependencies": {
"cucumber": "^4.0.0",
"react": "^16.3.0-alpha.1",
"react-native": "0.54.1",
"react-native-cli": "^2.0.1"
}
并在我的 scripts
对象中设置
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"jest": "jest",
"cucumber": "cucumber-js",
"gjest": "gherkin-jest",
"jestc": "jest-cucumber"
}
我的功能文件(位于 /features
)显示:
Feature: Create a new member account
As a new member
I want to create a member account
Scenario: Create a new user
When I create a new user with details:
| Username | mstelly |
| Email | my.email@example.com |
| Password | mySecretPassword |
Then the user is created successfully
我的 step_definitions 文件(位于 /features/step_definitions
)显示:
const { Given, Then, When } = require('cucumber');
const expect = require('expect');
When('I create a new user with details:', function(table) {
const data = table.rowsHash();
JSON.stringify(data);
});
Then('the user is created successfully', function() {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
当我执行脚本时:npm run cucumber features -r step_definitions/
,我收到以下控制台输出:
> mobile_gtm@0.0.1 cucumber /Users/michaelstelly/Documents/projects/mobile_gtm
> cucumber-js "features" "step_definitions/"
.P
Warnings:
1) Scenario: Create a new user # features/accountCreate.feature:5
✔ When I create a new user with details: # features/step_definitions/accountCreate.steps.js:4
| Username | mstelly |
| Email | my.email@example.com |
| Password | mySecretPassword |
? Then the user is created successfully # features/step_definitions/accountCreate.steps.js:9
Pending
1 scenario (1 pending)
2 steps (1 pending, 1 passed)
0m00.001s
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mobile_gtm@0.0.1 cucumber: `cucumber-js "features" "step_definitions/"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mobile_gtm@0.0.1 cucumber script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/michaelstelly/.npm/_logs/2018-03-29T11_57_24_218Z-debug.log
这就是我所有的信息。我收到黄瓜输出,但随后收到 npm
错误。它们可能与黄瓜无关,但在这一点上,我不能确定。
感谢您的帮助。有问题请追问。
我认为这应该发生。 https://github.com/cucumber/cucumber-js/issues/843#issuecomment-305331023
cucumber-js exits with status 1 if there are any undefined / pending / failed / ambiguous steps. It exits with status 0 if all steps pass.
我知道这个问题很老了,但我 运行 试图找到我自己问题的答案,希望这对未来有所帮助。
我是 cucumber
的新手,所以我不知道我的问题是由于缺乏理解引起的,还是实际上是脚本错误(我认为不太可能)。所以,我只是将正在发生的事情联系起来。通常,当我 运行 cucumber
时,我会得到 feature/scenario 输出,但脚本稍后会在执行过程中抛出错误。我了解到这可能是由我的 feature
或 steps_definition
文件中的错误引起的,但我不知道要查找什么。
我已将软件包安装为依赖项
"dependencies": {
"cucumber": "^4.0.0",
"react": "^16.3.0-alpha.1",
"react-native": "0.54.1",
"react-native-cli": "^2.0.1"
}
并在我的 scripts
对象中设置
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"jest": "jest",
"cucumber": "cucumber-js",
"gjest": "gherkin-jest",
"jestc": "jest-cucumber"
}
我的功能文件(位于 /features
)显示:
Feature: Create a new member account
As a new member
I want to create a member account
Scenario: Create a new user
When I create a new user with details:
| Username | mstelly |
| Email | my.email@example.com |
| Password | mySecretPassword |
Then the user is created successfully
我的 step_definitions 文件(位于 /features/step_definitions
)显示:
const { Given, Then, When } = require('cucumber');
const expect = require('expect');
When('I create a new user with details:', function(table) {
const data = table.rowsHash();
JSON.stringify(data);
});
Then('the user is created successfully', function() {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
当我执行脚本时:npm run cucumber features -r step_definitions/
,我收到以下控制台输出:
> mobile_gtm@0.0.1 cucumber /Users/michaelstelly/Documents/projects/mobile_gtm
> cucumber-js "features" "step_definitions/"
.P
Warnings:
1) Scenario: Create a new user # features/accountCreate.feature:5
✔ When I create a new user with details: # features/step_definitions/accountCreate.steps.js:4
| Username | mstelly |
| Email | my.email@example.com |
| Password | mySecretPassword |
? Then the user is created successfully # features/step_definitions/accountCreate.steps.js:9
Pending
1 scenario (1 pending)
2 steps (1 pending, 1 passed)
0m00.001s
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mobile_gtm@0.0.1 cucumber: `cucumber-js "features" "step_definitions/"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mobile_gtm@0.0.1 cucumber script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/michaelstelly/.npm/_logs/2018-03-29T11_57_24_218Z-debug.log
这就是我所有的信息。我收到黄瓜输出,但随后收到 npm
错误。它们可能与黄瓜无关,但在这一点上,我不能确定。
感谢您的帮助。有问题请追问。
我认为这应该发生。 https://github.com/cucumber/cucumber-js/issues/843#issuecomment-305331023
cucumber-js exits with status 1 if there are any undefined / pending / failed / ambiguous steps. It exits with status 0 if all steps pass.
我知道这个问题很老了,但我 运行 试图找到我自己问题的答案,希望这对未来有所帮助。