Merge pull request #28694 from g-plane/fix-jest

[jest] add missing matcher
This commit is contained in:
Sana Ajani
2018-09-07 14:27:07 -07:00
committed by GitHub
2 changed files with 13 additions and 0 deletions
+8
View File
@@ -481,6 +481,10 @@ declare namespace jest {
* If you know how to test something, `.not` lets you test its opposite.
*/
not: Matchers<R>;
/**
* Ensure that a mock function is called with specific arguments on an Nth call.
*/
nthCalledWith(nthCall: number, ...params: any[]): R;
/**
* Ensure that the nth call to a mock function has returned a specified value.
*/
@@ -504,6 +508,10 @@ declare namespace jest {
* Ensures that a mock function is called.
*/
toBeCalled(): R;
/**
* Ensures that a mock function is called an exact number of times.
*/
toBeCalledTimes(expected: number): R;
/**
* Ensure that a mock function is called with specific arguments.
*/
+5
View File
@@ -504,6 +504,9 @@ describe("", () => {
expect(jest.fn()).lastReturnedWith("jest");
expect(jest.fn()).lastReturnedWith({});
expect(jest.fn()).nthCalledWith(0, "jest");
expect(jest.fn()).nthCalledWith(1, {});
expect(jest.fn()).nthReturnedWith(0, "jest");
expect(jest.fn()).nthReturnedWith(1, {});
@@ -513,6 +516,8 @@ describe("", () => {
expect(jest.fn()).toBeCalled();
expect(jest.fn()).toBeCalledTimes(1);
expect(jest.fn()).toBeCalledWith();
expect(jest.fn()).toBeCalledWith("jest");
expect(jest.fn()).toBeCalledWith({}, {});