gpt4 book ai didi

javascript - Protractor 与 frisby API 集成

转载 作者:太空宇宙 更新时间:2023-11-04 00:29:15 27 4
gpt4 key购买 nike

我正在尝试将 frisby api 与 Protractor 集成。

    // An example configuration file.
exports.config = {

//seleniumAddress: 'http://localhost:4444/wd/hub',
directConnect: true,

// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},

// Framework to use. Jasmine is recommended.
framework: 'jasmine',

// Spec patterns are relative to the current working directory when
// protractor is called.
specs: ['/usr/local/lib/node_modules/protractor/SpecFiles/frisby_global_spec.js'],

// Options to be passed to Jasmine.
jasmineNodeOpts: {

defaultTimeoutInterval: 30000
}

};

//规范文件

   var frisby = require('frisby');

var base_url = "https://www.distelli.com/docs/tutorials/test-your-nodejs-with-jasmine";

describe("Hello World Server", function() {
it("first frisbytest", function () {
frisby.create('GET JSON data from an endpoint')
.get(base_url)
.expectStatus(200)
.expectHeader('Content-Type', 'application/json')
.toss();

});

});

但我遇到了以下错误

Error: TypeError: Cannot read property 'prototype' of undefined
at Object.<anonymous> (/usr/local/lib/node_modules/protractor/node_modules/frisby/lib/frisby.js:1125:17)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (/usr/local/lib/node_modules/protractor/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/usr/local/lib/node_modules/protractor/SpecFiles/frisby_global_spec.js:1:14)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (/usr/local/lib/node_modules/protractor/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at /usr/local/lib/node_modules/protractor/node_modules/jasmine/lib/jasmine.js:84:5
at Array.forEach (native)
at Jasmine.loadSpecs (/usr/local/lib/node_modules/protractor/node_modules/jasmine/lib/jasmine.js:83:18)
at Jasmine.execute (/usr/local/lib/node_modules/protractor/node_modules/jasmine/lib/jasmine.js:176:8)
at /usr/local/lib/node_modules/protractor/built/frameworks/jasmine.js:119:15
at Function.promise `enter code here`(/usr/local/lib/node_modules/protractor/node_modules/q/q.js:682:9)
at /usr/local/lib/node_modules/protractor/built/frameworks/jasmine.js:91:14
at _fulfilled (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:796:13)
at /usr/local/lib/node_modules/protractor/node_modules/q/q.js:556:49
at runSingle (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:137:13)
at flush (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:125:13)
at nextTickCallbackWith0Args (node.js:420:9)
at process._tickCallback (node.js:349:13)
[10:12:38] E/launcher - Process exited with error code 100

我是 javascript 测试新手。请告诉我 frisby api 和 Protractor 集成是否可行。如果是,您能帮忙调试这个问题吗?

最佳答案

您观察到的错误是由于 Protractor 默认支持 jasmine2,但 frisby 目前与 jasmine2 不兼容,目前仅支持 jasmine1,因此您无法将原生 frisby 组件与 Protractor 一起使用。

解决方法:我最近成功地将 Protractor 与 frisby 集成,因为 jasmine2 支持即将到来,现在在这方面有很好的工作,正在 frisby 的单独 PR 和分支中提供github 存储库。

您可以通过此解决方案将 frisby 的部分功能与 Protractor 结合使用,但很快就会提供全面支持!

所以你可以查看我的存储库-protractor-frisby关于如何通过此解决方案将 Protractor 与 frisby 集成。

注意:目前仅提供有限的支持,很快就会提供全面的支持!

关于javascript - Protractor 与 frisby API 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41629531/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com