Skip to content

Commit

Permalink
Update snapshot signature for Flow types (#1500)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippotto authored and novemberborn committed Sep 2, 2017
1 parent dd9e8b2 commit ded7ab8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js.flow
Expand Up @@ -69,7 +69,7 @@ type AssertContext = {
// Assert that contents matches regex.
regex(contents: string, regex: RegExp, message?: string): void;
// Assert that contents matches a snapshot.
snapshot(contents: any, message?: string): void;
snapshot: ((contents: any, message?: string) => void) & ((contents: any, options: {id: string}, message?: string) => void);
// Assert that contents does not match regex.
notRegex(contents: string, regex: RegExp, message?: string): void;
// Assert that error is falsy.
Expand Down
17 changes: 17 additions & 0 deletions test/flow-types/regression-1500.js.flow
@@ -0,0 +1,17 @@
/* @flow */

const test = require('../../index.js.flow');

test(t => {
t.snapshot({});
t.snapshot({}, "a message");
t.snapshot({}, {id: "snapshot-id"});
t.snapshot({}, {id: "snapshot-id"}, "a message");

// $ExpectError Message should be a string
t.snapshot({}, 1);
// $ExpectError unknownOption is an unknown options attribute
t.snapshot({}, { unknownOption: true });
// $ExpectError Message should be a string
t.snapshot({}, { id: "snapshot-id" }, 1);
});

0 comments on commit ded7ab8

Please sign in to comment.