Skip to content

Commit ded7ab8

Browse files
philippottonovemberborn
authored andcommitted
Update snapshot signature for Flow types (#1500)
1 parent dd9e8b2 commit ded7ab8

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

index.js.flow

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ type AssertContext = {
6969
// Assert that contents matches regex.
7070
regex(contents: string, regex: RegExp, message?: string): void;
7171
// Assert that contents matches a snapshot.
72-
snapshot(contents: any, message?: string): void;
72+
snapshot: ((contents: any, message?: string) => void) & ((contents: any, options: {id: string}, message?: string) => void);
7373
// Assert that contents does not match regex.
7474
notRegex(contents: string, regex: RegExp, message?: string): void;
7575
// Assert that error is falsy.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* @flow */
2+
3+
const test = require('../../index.js.flow');
4+
5+
test(t => {
6+
t.snapshot({});
7+
t.snapshot({}, "a message");
8+
t.snapshot({}, {id: "snapshot-id"});
9+
t.snapshot({}, {id: "snapshot-id"}, "a message");
10+
11+
// $ExpectError Message should be a string
12+
t.snapshot({}, 1);
13+
// $ExpectError unknownOption is an unknown options attribute
14+
t.snapshot({}, { unknownOption: true });
15+
// $ExpectError Message should be a string
16+
t.snapshot({}, { id: "snapshot-id" }, 1);
17+
});

0 commit comments

Comments
 (0)