@types/jest: relax type definition for toMatchSnapshot (#29371)

This commit is contained in:
timtrinidad
2018-10-10 15:58:49 -04:00
committed by Andy
parent dff15d9443
commit acfe3c89c2
2 changed files with 20 additions and 4 deletions

View File

@@ -665,7 +665,7 @@ declare namespace jest {
* This ensures that a value matches the most recent snapshot with property matchers.
* Check out [the Snapshot Testing guide](http://facebook.github.io/jest/docs/snapshot-testing.html) for more information.
*/
toMatchSnapshot<T extends {[P in keyof R]: Expect['any']}>(propertyMatchers: Partial<T>, snapshotName?: string): R;
toMatchSnapshot<T extends {[P in keyof R]: any}>(propertyMatchers: Partial<T>, snapshotName?: string): R;
/**
* This ensures that a value matches the most recent snapshot.
* Check out [the Snapshot Testing guide](http://facebook.github.io/jest/docs/snapshot-testing.html) for more information.
@@ -676,7 +676,7 @@ declare namespace jest {
* Instead of writing the snapshot value to a .snap file, it will be written into the source code automatically.
* Check out [the Snapshot Testing guide](http://facebook.github.io/jest/docs/snapshot-testing.html) for more information.
*/
toMatchInlineSnapshot<T extends {[P in keyof R]: Expect['any']}>(propertyMatchers: Partial<T>, snapshot?: string): R;
toMatchInlineSnapshot<T extends {[P in keyof R]: any}>(propertyMatchers: Partial<T>, snapshot?: string): R;
/**
* This ensures that a value matches the most recent snapshot with property matchers.
* Instead of writing the snapshot value to a .snap file, it will be written into the source code automatically.

View File

@@ -628,8 +628,16 @@ describe("", () => {
expect({
one: 1,
two: "2",
three: 3,
four: { four: 3 },
date: new Date(),
}).toMatchSnapshot({ one: expect.any(Number), date: expect.any(Date) });
}).toMatchSnapshot({
one: expect.any(Number),
// Leave 'two' to the auto-generated snapshot
three: 3,
four: { four: expect.any(Number) },
date: expect.any(Date),
});
expect({}).toMatchInlineSnapshot();
expect({}).toMatchInlineSnapshot("snapshot");
@@ -637,8 +645,16 @@ describe("", () => {
expect({
one: 1,
two: "2",
three: 3,
four: { four: 3 },
date: new Date(),
}).toMatchInlineSnapshot({ one: expect.any(Number), date: expect.any(Date) });
}).toMatchInlineSnapshot({
one: expect.any(Number),
// leave out two
three: 3,
four: { four: expect.any(Number) },
date: expect.any(Date),
});
expect(jest.fn()).toReturn();