lawl-spec-reporter
Version:
Spec reporter for jasmine, based on jasmine-spec-reporter, outputs in LolSpeak
488 lines (482 loc) • 19.2 kB
JavaScript
// Generated by CoffeeScript 1.9.2
(function() {
var SpecReporter;
require('./helpers/test-helper.coffee');
SpecReporter = require('../src/lawl-spec-reporter.js');
describe('spec reporter', function() {
addMatchers();
describe('with default options', function() {
beforeEach(function() {
return this.reporter = new SpecReporter();
});
describe('when spec', function() {
it('should report success', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite', function() {
return this.it('successful spec', function() {
return this.passed();
});
});
}).outputs).contains(/✓ SUCCESSFUL SPEC/);
});
it('should report failure', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite', function() {
return this.it('failed spec', function() {
return this.failed();
});
});
}).outputs).contains(/✗ FAILD SPEC/);
});
return it('should not report pending', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite', function() {
return this.xit('pending spec', function() {});
});
}).outputs).not.contains(/PENDING SPEC/);
});
});
describe('when failed spec', function() {
return it('should display with error messages', function() {
var outputs;
outputs = new Test(this.reporter, function() {
return this.describe('suite', function() {
return this.it('failed spec', function() {
this.failed('first failed assertion');
this.passed('passed assertion');
return this.failed('second failed assertion');
});
});
}).outputs;
expect(outputs).not.contains(/passed assertion/);
return expect(outputs).contains([' ✗ FAILD SPEC', ' - first failed assertion', ' - second failed assertion', '']);
});
});
describe('when suite', function() {
it('should display multiple specs', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite', function() {
this.it('spec 1', function() {
return this.passed();
});
return this.it('spec 2', function() {
return this.passed();
});
});
}).outputs).contains(['', ' SUITE', ' ✓ SPEC 1', ' ✓ SPEC 2', '']);
});
it('should display multiple suites', function() {
return expect(new Test(this.reporter, function() {
this.describe('suite 1', function() {
return this.it('spec 1', function() {
return this.passed();
});
});
return this.describe('suite 2', function() {
return this.it('spec 2', function() {
return this.passed();
});
});
}).outputs).contains(['', ' SUITE 1', ' ✓ SPEC 1', '', ' SUITE 2', ' ✓ SPEC 2', '']);
});
it('should display nested suite at first position', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite 1', function() {
this.describe('suite 2', function() {
return this.it('spec 1', function() {
return this.passed();
});
});
return this.it('spec 2', function() {
return this.passed();
});
});
}).outputs).contains(['', ' SUITE 1', '', ' SUITE 2', ' ✓ SPEC 1', '', ' ✓ SPEC 2', '']);
});
it('should display nested suite at last position', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite 1', function() {
this.it('spec 1', function() {
return this.passed();
});
return this.describe('suite 2', function() {
return this.it('spec 2', function() {
return this.passed();
});
});
});
}).outputs).contains(['', ' SUITE 1', ' ✓ SPEC 1', '', ' SUITE 2', ' ✓ SPEC 2', '']);
});
return it('should display multiple nested suites', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite 1', function() {
this.describe('suite 2', function() {
return this.it('spec 2', function() {
return this.passed();
});
});
return this.describe('suite 3', function() {
return this.it('spec 3', function() {
return this.passed();
});
});
});
}).outputs).contains(['', ' SUITE 1', '', ' SUITE 2', ' ✓ SPEC 2', '', ' SUITE 3', ' ✓ SPEC 3', '']);
});
});
return describe('when summary', function() {
it('should report success', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite', function() {
return this.it('spec', function() {
return this.passed();
});
});
}).summary).contains('EXECUTD 1 OV 1 SPEC SUCCES IN {time}.');
});
it('should report failure', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite', function() {
return this.it('spec', function() {
return this.failed();
});
});
}).summary).contains('EXECUTD 1 OV 1 SPEC (1 FAILD) IN {time}.');
});
xit('should report failures summary', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite 1', function() {
this.it('spec 1', function() {
return this.failed('failed assertion 1');
});
return this.describe('suite 2', function() {
return this.it('spec 2', function() {
return this.failed('failed assertion 2');
});
});
});
}).summary).contains([/[\s\S]*/, /OH NOES/, /[\s\S]*/, /1\) SUITE 1 SPEC 1/, /- failed assertion 1/, /[\s\S]*/]);
});
it('should report pending with success', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite', function() {
return this.xit('spec', function() {});
});
}).summary).contains('EXECUTD 0 OV 1 SPEC SUCCES (1 PENDIN) IN {time}.');
});
it('should report pending with failure', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite', function() {
this.xit('spec', function() {});
return this.it('spec', function() {
return this.failed();
});
});
}).summary).contains('EXECUTD 1 OV 2 SPECZ (1 FAILD) (1 PENDIN) IN {time}.');
});
xit('should report skipped with success', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite', function() {
this.it('spec', function() {});
return this.fit('spec', function() {});
});
}).summary).toContain('EXECUTD 1 OV 1 SPEC SUCCES (1 SKIPPED) IN {time}.');
});
return xit('should report skipped with failure and pending', function() {
return expect(new Test(this.reporter, function() {
this.fdescribe('suite', function() {
this.xit('spec', function() {});
return this.it('spec', function() {
return this.failed();
});
});
return this.describe('suite', function() {
this.it('spec', function() {});
return this.xit('spec', function() {});
});
}).summary).toContain('EXECUTD 1 OV 2 SPECZ (1 FAILD) (1 PENDING) (2 SKIPPED) IN {time}.');
});
});
});
describe('with stacktrace enabled', function() {
beforeEach(function() {
return this.reporter = new SpecReporter({
displayStacktrace: true
});
});
describe('when failed spec', function() {
return it('should display with error messages with stacktraces', function() {
var outputs;
outputs = new Test(this.reporter, function() {
return this.describe('suite', function() {
return this.it('failed spec', function() {
return this.failed('first failed assertion');
});
});
}).outputs;
expect(outputs).not.contains(/passed assertion/);
return expect(outputs).contains([' ✗ FAILD SPEC', ' - first failed assertion', ' {Stacktrace}', '']);
});
});
return describe('when summary', function() {
return xit('should report failures summary with stacktraces', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite 1', function() {
this.it('spec 1', function() {
return this.failed('failed assertion 1');
});
return this.describe('suite 2', function() {
return this.it('spec 2', function() {
return this.failed('failed assertion 2');
});
});
});
}).summary).contains([/[\s\S]*/, /OH NOES/, /[\s\S]*/, /1\) SUITE 1 SPEC 1/, /- failed assertion 1/, ' {Stacktrace}', /[\s\S]*/]);
});
});
});
describe('with failures summary disabled', function() {
beforeEach(function() {
return this.reporter = new SpecReporter({
displayFailuresSummary: false
});
});
return describe('when summary', function() {
return it('should not report failures summary', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite 1', function() {
this.it('spec 1', function() {
return this.failed('failed assertion 1');
});
return this.describe('suite 2', function() {
return this.it('spec 2', function() {
return this.failed('failed assertion 2');
});
});
});
}).summary).not.contains(/OH NOES/);
});
});
});
describe('with successful spec disabled', function() {
beforeEach(function() {
return this.reporter = new SpecReporter({
displaySuccessfulSpec: false
});
});
describe('when spec', function() {
return it('should not report success', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite', function() {
return this.it('successful spec', function() {
return this.passed();
});
});
}).outputs).not.contains(/SUCCESSFUL SPEC/);
});
});
return describe('when suite', function() {
it('should not display successful suite', function() {
var outputs;
outputs = new Test(this.reporter, function() {
return this.describe('suite', function() {
this.it('spec 1', function() {
return this.passed();
});
return this.it('spec 2', function() {
return this.passed();
});
});
}).outputs;
return expect(outputs).not.contains(/SUITE/);
});
return it('should display failed suite', function() {
var outputs;
outputs = new Test(this.reporter, function() {
return this.describe('suite', function() {
this.it('failed spec', function() {
return this.failed();
});
return this.it('successful spec', function() {
return this.passed();
});
});
}).outputs;
expect(outputs).contains(/SUITE/);
expect(outputs).contains(/FAILD SPEC/);
return expect(outputs).not.contains(/SUCCESSFUL SPEC/);
});
});
});
describe('with failed spec disabled', function() {
beforeEach(function() {
return this.reporter = new SpecReporter({
displayFailedSpec: false
});
});
describe('when spec', function() {
return it('should not report failed', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite', function() {
return this.it('failed spec', function() {
return this.failed();
});
});
}).outputs).not.contains(/FAILD SPEC/);
});
});
return describe('when suite', function() {
it('should not display fully failed suite', function() {
return expect(new Test(this.reporter, function() {
return this.describe('failed suite', function() {
this.it('spec 1', function() {
return this.failed();
});
return this.it('spec 2', function() {
return this.failed();
});
});
}).outputs).not.contains(/FAILD SUITE/);
});
return it('should display not fully failed suite', function() {
var outputs;
outputs = new Test(this.reporter, function() {
return this.describe('failed suite', function() {
this.it('successful spec', function() {
return this.passed();
});
return this.it('failed spec', function() {
return this.failed();
});
});
}).outputs;
expect(outputs).contains(/FAILD SUITE/);
expect(outputs).contains(/SUCCESSFUL SPEC/);
return expect(outputs).not.contains(/FAILD SPEC/);
});
});
});
describe('with pending spec enabled', function() {
beforeEach(function() {
return this.reporter = new SpecReporter({
displayPendingSpec: true
});
});
return describe('when spec', function() {
return it('should report pending', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite', function() {
return this.xit('pending spec', function() {});
});
}).outputs).contains(/- PENDING SPEC/);
});
});
});
describe('with spec duration enabled', function() {
beforeEach(function() {
return this.reporter = new SpecReporter({
displaySpecDuration: true
});
});
return describe('when spec', function() {
it('should report success', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite', function() {
return this.it('successful spec', function() {
return this.passed();
});
});
}).outputs).contains(/✓ SUCCESSFUL SPEC \(\{time}\)/);
});
return it('should report failure', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite', function() {
return this.it('failed spec', function() {
return this.failed();
});
});
}).outputs).contains(/✗ FAILD SPEC \(\{time}\)/);
});
});
});
describe('with prefixes set to empty strings', function() {
beforeEach(function() {
return this.reporter = new SpecReporter({
displayPendingSpec: true,
prefixes: {
success: '',
failure: '',
pending: ''
}
});
});
return describe('when spec', function() {
it('should report success', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite', function() {
return this.it('successful spec', function() {
return this.passed();
});
});
}).outputs).not.contains(/✓/);
});
it('should report failure', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite', function() {
return this.it('failed spec', function() {
return this.failed();
});
});
}).outputs).not.contains(/✗/);
});
return it('should report pending', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite', function() {
return this.xit('pending spec', function() {});
});
}).outputs).not.contains(/-/);
});
});
});
return describe('with prefixes set to valid strings', function() {
beforeEach(function() {
return this.reporter = new SpecReporter({
displayPendingSpec: true,
prefixes: {
success: 'Pass ',
failure: 'Fail ',
pending: 'Skip '
}
});
});
return describe('when spec', function() {
it('should report success', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite', function() {
return this.it('successful spec', function() {
return this.passed();
});
});
}).outputs).not.contains(/✓/);
});
it('should report failure', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite', function() {
return this.it('failed spec', function() {
return this.failed();
});
});
}).outputs).not.contains(/✗/);
});
return it('should report pending', function() {
return expect(new Test(this.reporter, function() {
return this.describe('suite', function() {
return this.xit('pending spec', function() {});
});
}).outputs).not.contains(/-/);
});
});
});
});
}).call(this);
//# sourceMappingURL=jasmine-spec-reporter.spec.js.map