我已经设置了一个工作的守夜环境,现在想使用黄瓜进行测试。我已遵循本指南:https ://www.youtube.com/watch?v=Jdlsv0CQ2CY&t=22s 。无论我尝试什么,我都无法使测试正常工作,我将其作为输出:
> cucumberpractice@1.0.0 test /Users/kieran/Documents/cucumberPractice
> cucumber-js --require cucumber.conf.js --require step-definitions --format node_modules/cucumber-pretty
Feature: Hacker News Search
Scenario: Searching Hacker News
Given I open Hacker News's home page
? undefined
Then the title is "Hacker News"
? undefined
And the Hacker News search form exists
? undefined
Warnings:
1) Scenario: Searching Hacker News # features/hackernews.feature:3
? Given I open Hacker News's home page
Undefined. Implement with the following snippet:
Given('I open Hacker News\'s home page', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
? Then the title is "Hacker News"
Undefined. Implement with the following snippet:
Then('the title is {string}', function (string) {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
? And the Hacker News search form exists
Undefined. Implement with the following snippet:
Then('the Hacker News search form exists', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
1 scenario (1 undefined)
3 steps (3 undefined)
0m00.000s
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cucumberpractice@1.0.0 test: `cucumber-js --require cucumber.conf.js --require step-definitions --format node_modules/cucumber-pretty`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cucumberpractice@1.0.0 test 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/kieran/.npm/_logs/2019-09-13T20_22_09_135Z-debug.log
我有 package.json、nightwatch.conf.js、cucumber.conf.js、hackernews.feature 和 hackernews.js 文件。
const { client } = require('nightwatch-api');
const { Given, Then } = require('cucumber');
Given(/^I open Hacker News's home page$/, () => {
return client
.url('https://news.ycombinator.com/')
.waitForElementVisible('body', 1000);
});
Then(/^the title is "([^"]*)"$/, title => {
return client.assert.title(title);
});
Then(/^the Hacker News search form exists$/, () => {
return client.assert.visible('input[name="q"]');
});
Feature: Hacker News Search
Scenario: Searching Hacker News
Given I open Hacker News's home page
Then the title is "Hacker News"
And the Hacker News search form exists
const chromedriver = require('chromedriver');
module.exports = {
"src_folders": ["tests"],
test_settings: {
default: {
webdriver: {
start_process: true,
server_path: chromedriver.path,
port: 4444,
cli_args: ['--port=4444']
},
desiredCapabilities: {
browserName: 'chrome'
}
}
}
};
{
"name": "cucumberpractice",
"version": "1.0.0",
"description": "Cucumber framework",
"main": "index.js",
"scripts": {
"test": "cucumber-js --require cucumber.conf.js --require step-definitions --format node_modules/cucumber-pretty"
},
"repository": {
"type": "git",
"url": "git+https://github.com/BinaryJava/nightwatch-testing.git"
},
"author": "Kieran Marriott",
"license": "ISC",
"bugs": {
"url": "https://github.com/BinaryJava/nightwatch-testing/issues"
},
"homepage": "https://github.com/BinaryJava/nightwatch-testing#readme",
"devDependencies": {
"chromedriver": "^76.0.1",
"nightwatch": "^1.2.2"
},
"dependencies": {
"cucumber": "^5.1.0",
"cucumber-pretty": "^1.5.2",
"nightwatch-api": "^2.3.0"
}
}
我该如何解决?