【问题标题】:Jasmine test makes no pass/fail report under webdriver.ioJasmine 测试在 webdriver.io 下没有通过/失败报告
【发布时间】:2014-10-29 00:14:32
【问题描述】:

像这样在 webdriver.io 下运行以下 jasmine 测试:node path/to/test/script.js,测试执行(拉起 Web 浏览器,访问目标页面),感谢最后一行,jasmine 'it' 功能(下)执行(没有最后一行,它们不会执行,尽管 'describe' 函数仍在运行)。

但是 jasmine 没有为“it”测试和“expect”断言提供任何类型的报告结果;茉莉花的控制台上没有任何内容。没有“通过/失败”结果,依此类推。

如何让茉莉花做报告,尤其是。詹金斯可以阅读的吗?

问题测试脚本:

var webdriverjs = require('foo-bar/node_modules/webdriverio');
var jasmine = require('foo-bar/node_modules/jasmine-node');

var options = {
    port: 4445,
    desiredCapabilities: {
        browserName: process.argv[2] || 'phantomjs'
    }
};

describe('my webdriverjs tests', function () {
  var client;

  jasmine.DEFAULT_TIMEOUT_INTERVAL = 9999999;

  beforeEach(function() {
    client = webdriverjs.remote(options);
    client.init();
  });

  it('shows the correct title', function (done) {
    client
      .url('http://localhost:4444').getTitle(function(err, title) {
        expect(title).toBe('foo bar');
      }).call( done );
  });

  afterEach(function(done) {
    client.end(done);
  });
});

jasmine.getEnv().execute();

注意:在这里交叉发布:https://groups.google.com/forum/#!topic/webdriverio/-EOrQ003B9I

【问题讨论】:

    标签: testing jasmine webdriver-io


    【解决方案1】:

    我在研究这个问题时遇到了一些相同的挑战。最大的问题是这个测试需要作为 jasmine 测试执行,而不是 webdriver 测试。

    decribe('my webdriverio tests with jasmine', function(){
        var client;
    
        beforeEach(function(){
            client = require('path/to/webdriverio').remote({
                desiredCapabilities: {browserName:'safari'}
            }).init.url('https://www.stackoverflow');
        }, 5000);
    
        afterEach(function(done){
            client.end(done);
        }, 5000);
    
        it('runs a very simple test',function(done){
           client.getTitle(function(err,result){
                expect(result).toBe('Stack Overflow');
           }).call(done);
        }, 5000);
    });
    

    现在要运行此测试,您只需从终端运行典型的jasmine-node 命令。

    【讨论】:

      【解决方案2】:

      这取决于您使用的命名约定。首先,您需要删除最后一行:jasmine.getEnv().execute();,然后运行带有--matchall 标志的jasmine-node 命令:

      jasmine-node --matchall path/to/test/script.js
      

      如果您将文件命名为 script_spec.js,那么您可以在没有 --matchall 标志的情况下运行它。

      这也是假设您已全局安装jasmine-node。如果你想使用本地的node_modules依赖,那么你需要运行这个命令:

      ./node_modules/jasmine-node/bin/jasmine-node --matchall path/to/test/script.js
      

      【讨论】:

        【解决方案3】:

        当你使用 jasmine-node 模块时,你应该运行你的规范

        node_modules/jasmine-node/bin/jasmine-node $TEST_DIRECTORY

        您的测试应该以 *spec.js、*spec.coffee 或 *spec.litcoffee 结尾,正如 docs 所说。

        并且jasmine.getEnv().execute();var jasmine = require('foo-bar/node_modules/jasmine-node'); 不应出现在您的脚本中。

        【讨论】:

          猜你喜欢
          • 2012-01-13
          • 1970-01-01
          • 2021-01-06
          • 2019-04-11
          • 2018-04-05
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多