From f73bb9c890ab76fb2a9a2f950b4c7a11a5f8285a Mon Sep 17 00:00:00 2001 From: Bastien Caudan Date: Tue, 17 Jan 2017 22:36:04 +0100 Subject: [PATCH] jasmine: fix CustomReporter.jasmineDone signature (#14032) - Extract RunDetails interface - Remove test reporter with wrong signature --- jasmine/index.d.ts | 26 ++++++++++++++------------ jasmine/jasmine-tests.ts | 21 +++------------------ 2 files changed, 17 insertions(+), 30 deletions(-) diff --git a/jasmine/index.d.ts b/jasmine/index.d.ts index 5dcf813628..7bf232acba 100644 --- a/jasmine/index.d.ts +++ b/jasmine/index.d.ts @@ -370,13 +370,18 @@ declare namespace jasmine { } interface CustomReporterResult { - description: string, - failedExpectations?: FailedExpectation[], - fullName: string, - id: string; - passedExpectations?: PassedExpectation[], - pendingReason?: string; - status?: string; + description: string, + failedExpectations?: FailedExpectation[], + fullName: string, + id: string; + passedExpectations?: PassedExpectation[], + pendingReason?: string; + status?: string; + } + + interface RunDetails { + failedExpectations: ExpectationResult[]; + order: jasmine.Order } interface CustomReporter { @@ -385,7 +390,7 @@ declare namespace jasmine { specStarted?(result: CustomReporterResult): void; specDone?(result: CustomReporterResult): void; suiteDone?(result: CustomReporterResult): void; - jasmineDone?(): any; + jasmineDone?(runDetails: RunDetails): void; } interface Runner { @@ -549,10 +554,7 @@ declare namespace jasmine { finished: boolean; result: any; messages: any; - runDetails: { - failedExpectations: ExpectationResult[]; - order: jasmine.Order - } + runDetails: RunDetails new (): any; diff --git a/jasmine/jasmine-tests.ts b/jasmine/jasmine-tests.ts index 87497e90c2..77aa8cbee3 100644 --- a/jasmine/jasmine-tests.ts +++ b/jasmine/jasmine-tests.ts @@ -926,7 +926,7 @@ var myReporter: jasmine.CustomReporter = { } console.log(result.passedExpectations.length); }, - + suiteDone: function (result: jasmine.CustomReporterResult) { console.log('Suite: ' + result.description + ' was ' + result.status); for (var i = 0; i < result.failedExpectations.length; i++) { @@ -935,29 +935,14 @@ var myReporter: jasmine.CustomReporter = { } }, - jasmineDone: function() { + jasmineDone: function(runDetails: jasmine.RunDetails) { console.log('Finished suite'); + console.log('Random:', runDetails.order.random); } }; jasmine.getEnv().addReporter(myReporter); -// test for custom reporter which return ES6 Promise in jasmineDone(): -var myShortReporter: jasmine.CustomReporter = { - jasmineDone: function() { - return new Promise(function(resolve, reject) { - setTimeout(() => resolve(), 10000); - }); - } -} - -var jasmineDoneResolved: Promise = myShortReporter.jasmineDone(); -jasmineDoneResolved.then(() => { - console.log("[ShortReporter] : jasmineDone Resolved"); -}); - -jasmine.getEnv().addReporter(myShortReporter); - describe("Randomize Tests", function() { it("should allow randomization of the order of tests", function() { expect(function() {