我正在使用Protractor和Cucumber(js).我想生成报告文件,就像使用Cucumber-JVM版本一样.我看过使用Protractor和Jasmine的例子,但实际上没有使用Cucumber.
使用此配置时如何生成报告?
最终目标是在Jenkins或其他任何地方发布此报告(如果它们是直接在HTML中生成的).
谢谢!
从0.20.1开始, Cucumber现在在Protractor中得到了完全支持,但我正在努力寻找有关如何正确配置它的任何文档.知道如何设置world.js吗?
我在https://github.com/whyvez/angular-cucumber-example/blob/master/features/support/world.coffee找到了这个例子,但我不确定你是否还需要指定所有的需求模块和配置作为量角器配置文件(referenceConf.js)将拥有所有这些信息.
assert = require 'assert'
path = require 'path'
protractor = require 'protractor'
webdriver = require 'selenium-webdriver'
driver = new webdriver.Builder().
usingServer('http://localhost:4444/wd/hub').
withCapabilities(webdriver.Capabilities.chrome()).
build()
driver.manage().timeouts().setScriptTimeout(100000)
ptor = protractor.wrapDriver driver
class World
constructor: (callback) ->
@browser = ptor
@By = protractor.By
@assert = assert
callback()
module.exports.World = World
Run Code Online (Sandbox Code Playgroud) 我正在使用Jest进行单元测试,而我正在整合Cucumber.js以运行用Gherkin编写的规范.
我已经完成所有设置并且它正在运行,但我遇到了一个问题:我如何使用Jest expect
?我可以使用chai
's,但我想expect
在我的单元测试和我的步骤定义之间保持相同的语法(我不希望to.equal
在我的步骤定义和toEqual
单元测试中).
我怎样才能做到这一点?经过一番挖掘后,似乎Jest依赖于expect
npm包.我可以在我的内容中明确依赖该包package.json
,但我更倾向于使用我现有的Jest依赖项.也许那是不可能的,但我希望是这样.
另一个选择是以某种方式用Jest测试运行器执行Gherkin规范.我也对这个选项持开放态度.目前我正在通过cucumber.js
与我的Jest测试运行器分开调用来运行它们.
我如何才能获得当前的特征,场景和世界步骤?
我试过这种方式,但我只有Scenario的名称和描述:
module.exports = function () {
/**
* Before each scenario
*/
this.Before(function (scenario, callback) {
console.log(scenario);
callback();
});
};
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助.
我对cucumberjs有疑问.我找不到一种方法来确保将具有给定选择器的元素呈现到DOM中.我和Chai一起使用cucjs. https://github.com/cucumber/cucumber-js isPresent返回对象 - 无论元素是否存在.所以问题是如何检查DOM中是否存在元素.
我将编辑问题以分享一个学到的课程.我阅读文档也想感谢Nathan Thompson.isPresent()返回一个promise,该promise将解析该元素是否存在于页面上.
http://angular.github.io/protractor/#/api?view=Protractor.prototype.isElementPresent
代码示例有点误导.因此,如果您希望在DOM中存在具有给定选择器的元素,则必须使用以下内容:
element(by.id('someId')).isPresent().then(function(isElementVisible) {
expect(isElementVisible).to.be.true;
});
Run Code Online (Sandbox Code Playgroud)
或者使用带有承诺的柴.
expect(element.isPresent()).to.eventually.be.false
Run Code Online (Sandbox Code Playgroud)
然而,"最终"这个词听起来很不愉快.我们希望确保最终不确定.:)
在这里可以看到关于这个问题的文章到我的个人博客中.
这个问题也应该适用于requirejs.
具体内容:
我问的原因是因为我只有几个非常基本的黄瓜测试,有时我得到错误(不一致)涉及超时或等待与页面同步等.其他时间我的测试通过并且没有给出超时错误.关于这些问题,没有大量的权威信息.主要只是一堆SO和github问题.
将Protractor与SystemJS一起使用的正确方法是什么?
我试图找出一个办法以同样的方式使用,或者还好说,类似的方式,该标记选项cucumberJS
用了protractor
,但与Jasmin
E,有没有办法来标记不同的场景,如:@smoke
,@regression
等等.然后告诉控制台运行那些?
我拒绝使用Cucumber
,因为它的支持它似乎变得片状!
任何帮助都感激不尽!
这里是 Javascript/Cypress 的相对新手。我正在使用 Cypress Cucumber.js 插件运行一些测试。问题是我无法让我的步骤按顺序运行 - 由于 js 的异步性质,“Then”步骤在“Given”等之前运行。显然,这会成为一个问题,因为测试会失败!
我的问题:
1)我们如何使用异步代码使黄瓜步骤始终按顺序运行?我在这里看到了类似的问题:How to wait for a JavaScript Promise to resolve before resuming function? ,并根据我对给定块应用 async/await 的响应,希望它会在我的步骤中强制执行命令,但这不起作用。
这是我的功能文件:
Given I get the data from CMS
Then I can verify that the title is the same as the CMA title in tab "0"
And I can verify that the link is the correct link in tab "0"
Run Code Online (Sandbox Code Playgroud)
脚步:
Given('I get the data from CMS', async() => {
let api = await …
Run Code Online (Sandbox Code Playgroud) 我有一个简单的项目,基本上......
export class Application{
constructor(...){
...
}
async run(){
console.log("I Ran!");
}
}
Run Code Online (Sandbox Code Playgroud)
我想使用 Cukes 运行它,所以我按照以下步骤操作并使其正常工作(注意 .cjs 扩展名以表明它是一个 cjs 文件)
// features/basic.feature
Feature: Hello World
Scenario: Hello World
Given I start the app
When it is running
Then I see the console
// features/support/steps.cjs
const { Given, When, Then } = require("@cucumber/cucumber");
Given("I start the app", function () {
// TODO: Setup child process
return
});
When("it is running", function () {
// TODO: Execute using Worker …
Run Code Online (Sandbox Code Playgroud) 我试图在Visual Studio代码中调试Cucumber方案,并在下面进行了更改launch.json
.
{
"name": "e2e",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}\\node_modules\\.bin\\cucumber-js",
"stopOnEntry": false,
"args": ["--no-timeouts", "--colors"],
"cwd": "${workspaceRoot}",
"runtimeExecutable": null,
"outFiles": [
"${workspaceRoot}\\features\\step_definitions\\*.js"
]
},
Run Code Online (Sandbox Code Playgroud)
但是,我无法使用上述配置运行调试会话.步骤def.我在JavaScript中创建的文件.那么,如果看起来不错,只需要上面的脚本帮助吗?
javascript-debugger visual-studio-debugging cucumberjs visual-studio-code
cucumberjs ×10
javascript ×7
cucumber ×5
protractor ×5
angularjs ×1
bdd ×1
chai ×1
cypress ×1
es6-modules ×1
jasmine ×1
jestjs ×1
node.js ×1
report ×1
reporting ×1
testing ×1