- xit
- it with a null function body ( it("should be pending");
- calling pending() inside a spec
- having a spec without any expectations
Pending and Filtered specs now call Reporter interface specStarted so that reporting acts as expected.
Pending and Filtered spec names are present and styled in the HTML reporter
Using xit used to disable a spec. Disabling is now just when a spec is filtered out at run time (usually w/ the reporter).
Suites are still disabled with xdescribe and means its specs are never executed.
182 lines
5.0 KiB
JavaScript
182 lines
5.0 KiB
JavaScript
xdescribe('JsApiReporter (integration specs)', function() {
|
|
describe('results', function() {
|
|
var reporter, spec1, spec2;
|
|
var env;
|
|
var suite, nestedSuite, nestedSpec;
|
|
|
|
beforeEach(function() {
|
|
env = new jasmine.Env();
|
|
env.updateInterval = 0;
|
|
|
|
suite = env.describe("top-level suite", function() {
|
|
spec1 = env.it("spec 1", function() {
|
|
this.expect(true).toEqual(true);
|
|
|
|
});
|
|
|
|
spec2 = env.it("spec 2", function() {
|
|
this.expect(true).toEqual(false);
|
|
});
|
|
|
|
nestedSuite = env.describe("nested suite", function() {
|
|
nestedSpec = env.it("nested spec", function() {
|
|
expect(true).toEqual(true);
|
|
});
|
|
});
|
|
|
|
});
|
|
|
|
reporter = new jasmine.JsApiReporter(jasmine);
|
|
env.addReporter(reporter);
|
|
|
|
env.execute();
|
|
|
|
});
|
|
|
|
it('results() should return a hash of all results, indexed by spec id', function() {
|
|
var expectedSpec1Results = {
|
|
result: "passed"
|
|
},
|
|
expectedSpec2Results = {
|
|
result: "failed"
|
|
};
|
|
expect(reporter.results()[spec1.id].result).toEqual('passed');
|
|
expect(reporter.results()[spec2.id].result).toEqual('failed');
|
|
});
|
|
|
|
it("should return nested suites as children of their parents", function() {
|
|
expect(reporter.suites()).toEqual([
|
|
{ id: 0, name: 'top-level suite', type: 'suite',
|
|
children: [
|
|
{ id: 0, name: 'spec 1', type: 'spec', children: [ ] },
|
|
{ id: 1, name: 'spec 2', type: 'spec', children: [ ] },
|
|
{ id: 1, name: 'nested suite', type: 'suite',
|
|
children: [
|
|
{ id: 2, name: 'nested spec', type: 'spec', children: [ ] }
|
|
]
|
|
},
|
|
]
|
|
}
|
|
]);
|
|
});
|
|
|
|
describe("#summarizeResult_", function() {
|
|
it("should summarize a passing result", function() {
|
|
var result = reporter.results()[spec1.id];
|
|
var summarizedResult = reporter.summarizeResult_(result);
|
|
expect(summarizedResult.result).toEqual('passed');
|
|
expect(summarizedResult.messages.length).toEqual(0);
|
|
});
|
|
|
|
it("should have a stack trace for failing specs", function() {
|
|
var result = reporter.results()[spec2.id];
|
|
var summarizedResult = reporter.summarizeResult_(result);
|
|
expect(summarizedResult.result).toEqual('failed');
|
|
expect(summarizedResult.messages[0].trace.stack).toEqual(result.messages[0].trace.stack);
|
|
});
|
|
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
describe("JsApiReporter", function() {
|
|
|
|
it("knows when a full environment is started", function() {
|
|
var reporter = new jasmine.JsApiReporter();
|
|
|
|
expect(reporter.started).toBe(false);
|
|
expect(reporter.finished).toBe(false);
|
|
|
|
reporter.jasmineStarted();
|
|
|
|
expect(reporter.started).toBe(true);
|
|
expect(reporter.finished).toBe(false);
|
|
});
|
|
|
|
it("knows when a full environment is done", function() {
|
|
var reporter = new jasmine.JsApiReporter();
|
|
|
|
expect(reporter.started).toBe(false);
|
|
expect(reporter.finished).toBe(false);
|
|
|
|
reporter.jasmineStarted();
|
|
reporter.jasmineDone();
|
|
|
|
expect(reporter.finished).toBe(true);
|
|
});
|
|
|
|
it("defaults to 'loaded' status", function() {
|
|
var reporter = new jasmine.JsApiReporter();
|
|
|
|
expect(reporter.status()).toEqual('loaded');
|
|
});
|
|
|
|
it("reports 'started' when Jasmine has started", function() {
|
|
var reporter = new jasmine.JsApiReporter();
|
|
|
|
reporter.jasmineStarted();
|
|
|
|
expect(reporter.status()).toEqual('started');
|
|
});
|
|
|
|
it("reports 'done' when Jasmine is done", function() {
|
|
var reporter = new jasmine.JsApiReporter();
|
|
|
|
reporter.jasmineDone();
|
|
|
|
expect(reporter.status()).toEqual('done');
|
|
});
|
|
|
|
it("tracks a suite", function() {
|
|
var reporter = new jasmine.JsApiReporter();
|
|
|
|
reporter.suiteStarted({
|
|
id: 123,
|
|
description: "A suite"
|
|
});
|
|
|
|
var suites = reporter.suites();
|
|
|
|
expect(suites).toEqual({123: {id: 123, description: "A suite"}});
|
|
|
|
reporter.suiteDone({
|
|
id: 123,
|
|
description: "A suite",
|
|
status: 'passed'
|
|
});
|
|
|
|
expect(suites).toEqual({123: {id: 123, description: "A suite", status: 'passed'}});
|
|
});
|
|
|
|
describe("#specResults", function() {
|
|
var reporter, specResult1, specResult2;
|
|
beforeEach(function() {
|
|
reporter = new jasmine.JsApiReporter();
|
|
specResult1 = {
|
|
id: 1,
|
|
description: "A spec"
|
|
};
|
|
specResult2 = {
|
|
id: 2,
|
|
description: "Another spec"
|
|
};
|
|
|
|
reporter.specDone(specResult1);
|
|
reporter.specDone(specResult2);
|
|
});
|
|
|
|
it("should return a slice of results", function() {
|
|
expect(reporter.specResults(0, 1)).toEqual([specResult1]);
|
|
expect(reporter.specResults(1, 1)).toEqual([specResult2]);
|
|
});
|
|
|
|
describe("when the results do not exist", function() {
|
|
it("should return a slice of shorter length", function() {
|
|
expect(reporter.specResults(0, 3)).toEqual([specResult1, specResult2]);
|
|
expect(reporter.specResults(2, 3)).toEqual([]);
|
|
});
|
|
});
|
|
});
|
|
});
|