如何将自定义数据传递给Jasmine或Reporter?

时间:2016-08-10 21:48:01

标签: jasmine

我使用Ax(AxeBuilder)进行了一些Protractor测试,如下所示:

var AxeBuilder = require('path_to_the/axe-webdriverjs');

describe('Page under test', function() {
    'use strict';

    it('should be accessible', function() {
        AxeBuilder(browser.driver).analyze(function(results) {
            expect(results.violations.length).toBe(0);
        });
    });

});

我如何将results.violations传递给Jasmine,以便在我的Jasmine Reporter中报告?

我目前正在使用以下Jasmine JSON Reporter:

https://github.com/DrewML/jasmine-json-test-reporter

但我最终会自定义此输出HTML。

1 个答案:

答案 0 :(得分:1)

我最终找到了解决方法。

事实证明,解决方案是编写一个自定义的Jasmine匹配器,如下所示:http://jasmine.github.io/2.4/custom_matcher.html

这允许您控制传递给result.message的信息。