首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >黄瓜测试示例未运行

黄瓜测试示例未运行
EN

Stack Overflow用户
提问于 2019-09-13 20:37:03
回答 2查看 1.2K关注 0票数 1

我已经设置了一个工作的夜间工作环境,现在想使用黄瓜进行测试。我遵循了这个指南:https://www.youtube.com/watch?v=Jdlsv0CQ2CY&t=22s。无论我尝试了什么,我都不能让测试工作起来,我把它作为输出:

代码语言:javascript
复制
> 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文件。

代码语言:javascript
复制
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"]');
});
代码语言:javascript
复制
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
代码语言:javascript
复制
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'
      }
    }
  }
};
代码语言:javascript
复制
{
  "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"
  }
}

我该怎么解决这个问题?

EN

回答 2

Stack Overflow用户

发布于 2019-12-24 17:15:27

您可能会在package.json文件中为步骤定义文件提供错误的路径,

“脚本”:{“测试”:“黄瓜-js--需要step-definitions --格式节点_模块/黄瓜-漂亮”},

例如,我的,这是包中的代码,json,

“脚本”:{“测试”:“黄瓜-js--需要cucumber.conf.js --需要测试--格式化节点_模块/黄瓜--漂亮”},

“--要求测试”:这里的"test“是我的特性文件和我的步骤定义文件存在的位置文件夹。

票数 0
EN

Stack Overflow用户

发布于 2022-11-13 15:54:28

而不是场景:搜索黑客新闻,你必须把场景大纲:搜索黑客新闻添加示例

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57930064

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档