我是cucumber新手,所以我不知道我的问题是因为缺乏理解,还是因为脚本的错误(不太可能是我认为的那样)。所以,我只想说说发生了什么。通常,当我运行cucumber时,我会得到特性/场景输出,但是脚本稍后会在执行过程中抛出错误。我读到这可能是由我的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错误。他们可能与黄瓜无关,但在这一点上,我不能肯定。
我们很感激你的帮助。如果你有问题,请问。
发布于 2020-08-31 16:10:30
我想这是应该发生的。https://github.com/cucumber/cucumber-js/issues/843#issuecomment-305331023
如果存在任何未定义/挂起/失败/不明确的步骤,则退出状态为1的黄瓜-js。如果所有步骤都通过,则退出状态为0。
我知道这个问题很古老,但是我偶然发现了这个问题的答案,希望它能帮助我的未来。
https://stackoverflow.com/questions/49556045
复制相似问题