【发布时间】:2021-01-25 22:54:57
【问题描述】:
这是我第一次使用 CodeceptJs,当 IDE 要求我使用 implement steps for my scenario 时,我正在努力运行我的功能文件,但这已经完成,所以我觉得它可能正在搜索它们除了 codecept.conf.js 文件下指定的其他地方吗?
当我在终端上运行 npx codeceptjs gherkin:steps 或 sn-ps 时,我收到这条消息说Could not include object Step Definition from ./step_definitions/steps.js from module '/Users/myUser/IdeaProjects/codeceptjs_webdriver/step_definitions/steps.js' The "from" argument must be of type string. Received undefined 。
然后,我将 step_definitions 文件夹移动到功能内部,因为读取这将是这些功能的默认位置,现在得到一个 inject is not defined error,这可能是我遇到问题的实际原因,但不知道该怎么做修复它。
我在 IntelliJ Ultimate、Webstorm 和 VSCode 上进行了尝试,但在所有这些上都得到了相同的结果。
基本功能
Feature: Business rules
In order to achieve my goals
As a persona
I want to be able to interact with a system
Scenario: do something
Given I have a defined step
steps.js
const {Given} = require('cucumber');
const {I} = inject();
Given(/^I have a defined step$/, function () {
I.amOnPage('/');
});
codecept.conf.js
exports.config = {
output: './output',
helpers: {
WebDriver: {
url: 'https:www.google.com',
browser: 'chrome'
}
},
include: {
I: './steps_file.js'
},
mocha: {},
bootstrap: null,
teardown: null,
hooks: [],
gherkin: {
features: './features/*.feature',
steps: ['./step_definitions/steps.js']
},
plugins: {
screenshotOnFail: {
enabled: true
},
pauseOnFail: {},
retryFailedStep: {
enabled: true
},
tryTo: {
enabled: true
}
},
tests: './*_test.js',
name: 'codeceptjs_webdriver'
}
package.json
{
"name": "codeceptjs_webdriver",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"codeceptjs": "^3.0.0",
"cucumber": "^5.0.1"
},
"dependencies": {
"@codeceptjs/configure": "^0.6.0"
},
"description": ""
}
IntelliJ Ultimate 2020.2
这里是我的Github repo
非常感谢。
【问题讨论】:
标签: intellij-idea cucumber cucumberjs codeceptjs