我正在尝试将frisby api与量角器集成。

    // 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 testing的新手,请让我知道frisby api和量角器集成是否可行。如果是,您可以帮助调试问题吗?

最佳答案

您正在观察的错误是由于Protractor默认情况下支持jasmine2,但frisby当前与jasmine2不兼容,到目前为止它仅支持jasmine1,因此您无法将本机frisby组件与protractor一起使用。

解决方法:我最近设法将量角器与frisby集成在一起,因为对此已经有了jasmine2的支持,现在在frisby github存储库中的单独PR和分支中提供了出色的工作。

您可以将frisby的某些功能与量角器配合使用,但很快就会获得全面支持!

因此,您可以通过此方法来查看我的关于如何将量角器与frisby集成的报告protractor-frisby

注意:到目前为止,此功能仅提供有限的支持,不久将提供全面支持!

10-04 22:03