Skip to content
Permalink
Browse files
fix(jasmine): Jasmine scenarios synchronise with Serenity/JS
  • Loading branch information
jan-molak committed May 15, 2019
1 parent 3ee5f0b commit 42c28a6e8444fc146e184773cbe3940e3ed5d696
Showing with 20 additions and 2 deletions.
  1. +18 −2 packages/jasmine/spec/monkeyPatched.spec.ts
  2. +2 −0 packages/jasmine/src/bootstrap.ts
@@ -1,16 +1,22 @@
import { expect } from '@integration/testing-tools';
import * as sinon from 'sinon';
import serenityReporterForJasmine = require('../src');

describe('@serenity-js/jasmine', () => {

beforeEach(() => {
const env = {
afterEach: sinon.spy(),
};

(global as any).jasmine = {
Spec: function Spec() {
this.result = {};
},
Suite: function Suite() {
this.result = {};
},
getEnv: () => env,
};
});

@@ -28,7 +34,7 @@ describe('@serenity-js/jasmine', () => {
const spec = new (global as any).jasmine.Spec();

expect(spec.result.location.path).to.match(/monkeyPatched.spec.ts$/);
expect(spec.result.location.line).to.equal(28);
expect(spec.result.location.line).to.equal(34);
expect(spec.result.location.column).to.equal(30);
});

@@ -58,9 +64,19 @@ describe('@serenity-js/jasmine', () => {
const spec = new (global as any).jasmine.Suite();

expect(spec.result.location.path).to.match(/monkeyPatched.spec.ts$/);
expect(spec.result.location.line).to.equal(58);
expect(spec.result.location.line).to.equal(64);
expect(spec.result.location.column).to.equal(30);
});
});
});

/**
* @test {bootstrap}
* @test {monkeyPatched}
*/
it('registers an afterEach hook to ensure Serenity/JS is synchronised with Jasmine', () => {
serenityReporterForJasmine();

expect((global as any).jasmine.getEnv().afterEach).to.have.been.calledOnce; // tslint:disable-line:no-unused-expression
});
});
@@ -24,5 +24,7 @@ export function bootstrap() {
jasmine.Suite = monkeyPatched(jasmine.Suite);
jasmine.Spec = monkeyPatched(jasmine.Spec);

jasmine.getEnv().afterEach(() => serenity.waitForNextCue());

return new SerenityReporterForJasmine(serenity);
}

0 comments on commit 42c28a6

Please sign in to comment.