From 5cde7adaa686b32c3302933470303a9c146d4ba9 Mon Sep 17 00:00:00 2001 From: cexbrayat Date: Fri, 26 Oct 2018 14:32:37 +0200 Subject: [PATCH] Jasmine: Adds withContext method on Matcher Jasmine 3.3.0 introduced a new method called `withContext` to provide additional context to an expectation. See https://github.com/jasmine/jasmine/blob/master/release_notes/3.3.0.md --- types/jasmine/index.d.ts | 6 ++++++ types/jasmine/jasmine-tests.ts | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/types/jasmine/index.d.ts b/types/jasmine/index.d.ts index 254714ff94..8ce2b85bb5 100644 --- a/types/jasmine/index.d.ts +++ b/types/jasmine/index.d.ts @@ -448,6 +448,12 @@ declare namespace jasmine { toThrowError(message?: string | RegExp): boolean; toThrowError(expected?: new (...args: any[]) => Error, message?: string | RegExp): boolean; + /** + * Add some context for an expect. + * @param message - Additional context to show when the matcher fails + */ + withContext(message: string): Matchers; + not: Matchers; Any: Any; diff --git a/types/jasmine/jasmine-tests.ts b/types/jasmine/jasmine-tests.ts index e96293ced4..11bfbca2b2 100644 --- a/types/jasmine/jasmine-tests.ts +++ b/types/jasmine/jasmine-tests.ts @@ -246,6 +246,12 @@ describe("A spec", () => { }); }); +describe("withContext", () => { + it("can be used after an expectation", () => { + expect(1).withContext('context message').toBe(1); + }); +}); + xdescribe("A spec", () => { var foo: number;