Skip to content
Permalink
Browse files
fix(jasmine): ensure the async work queue is empty before the suite i…
…s marked as completed

closes #56
  • Loading branch information
jan-molak committed Jan 19, 2020
1 parent 5097057 commit ad5a2b67a8e2c22c530ea065cef541548d06f3d0
@@ -2,12 +2,13 @@ const
path = require('path'),
{ ConsoleReporter } = require('@serenity-js/console-reporter'),
{ ArtifactArchiver } = require('@serenity-js/core'),
{ Photographer, TakePhotosOfInteractions } = require('@serenity-js/protractor'),
{ Photographer, TakePhotosOfInteractions, TakePhotosOfFailures } = require('@serenity-js/protractor'),
{ SerenityBDDReporter } = require('@serenity-js/serenity-bdd');

exports.config = {
chromeDriver: require('chromedriver/lib/chromedriver').path,
SELENIUM_PROMISE_MANAGER: false,
// restartBrowserBetweenTests: false,

directConnect: true,

@@ -24,7 +25,7 @@ exports.config = {
runner: 'jasmine',
crew: [
ArtifactArchiver.storingArtifactsAt('./target/site/serenity'),
Photographer.whoWill(TakePhotosOfInteractions),
Photographer.whoWill(TakePhotosOfFailures),
new SerenityBDDReporter(),
ConsoleReporter.forDarkTerminals(),
]
@@ -10,7 +10,6 @@ describe('Jasmine', () => {
let Jasmine;

beforeEach(() => {
require('fs').appendFileSync(require('path').resolve(process.cwd(), 'jasmine.log'), ` >> [spec] new actor created\n`);
Jasmine = Actor.named('Jasmine').whoCan(
BrowseTheWeb.using(protractor.browser),
);
@@ -17,6 +17,7 @@ describe('JasmineAdapter', () => {
getEnv() {
return {
beforeEach: () => void 0,
afterAll: () => void 0,
};
},
};
@@ -9,6 +9,7 @@ describe('@serenity-js/jasmine', () => {
beforeEach(() => {
const env = {
beforeEach: sinon.spy(),
afterAll: sinon.spy(),
};

jasmine = {
@@ -78,9 +79,10 @@ describe('@serenity-js/jasmine', () => {
* @test {bootstrap}
* @test {monkeyPatched}
*/
it('registers a beforeEach hook to ensure Serenity/JS is synchronised with Jasmine', () => {
it('registers a beforeEach and afterAll hooks to ensure Serenity/JS is synchronised with Jasmine', () => {
serenityReporterForJasmine(jasmine);

expect(jasmine.getEnv().beforeEach).to.have.been.calledOnce; // tslint:disable-line:no-unused-expression
expect(jasmine.getEnv().beforeEach).to.have.been.calledOnce; // tslint:disable-line:no-unused-expression
expect(jasmine.getEnv().afterAll).to.have.been.calledOnce; // tslint:disable-line:no-unused-expression
});
});
@@ -59,7 +59,6 @@ export class JasmineAdapter {

runner.addReporter(reporter(jasmine));

// todo: wait for the wip queue to drain here again?
runner.onComplete((passed: boolean) => resolve());

runner.configureDefaultReporter(this.config);
@@ -26,6 +26,7 @@ export function bootstrap(jasmine = (global as any).jasmine) {
jasmine.Spec = monkeyPatched(jasmine.Spec);

jasmine.getEnv().beforeEach(() => serenity.waitForNextCue());
jasmine.getEnv().afterAll(() => serenity.waitForNextCue());

return new SerenityReporterForJasmine(serenity);
}

0 comments on commit ad5a2b6

Please sign in to comment.