Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[ignore]
<PROJECT_ROOT>/node_modules/.*
<PROJECT_ROOT>/.*\.js$

[options]
emoji=true
suppress_comment=\\(.\\|\n\\)*\\$ExpectError
4 changes: 2 additions & 2 deletions index.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ type AssertContext = {
};
// Assert that function doesn't throw an error or promise resolves.
notThrows: {
notThrows<U>(value: PromiseLike<U>, message?: string): Promise<U>;
notThrows(value: () => mixed, message?: string): void;
<U>(value: PromiseLike<U>, message?: string): Promise<U>;
(value: () => mixed, message?: string): void;
};
// Assert that contents matches regex.
regex(contents: string, regex: RegExp, message?: string): void;
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"node": ">=4"
},
"scripts": {
"test": "xo && nyc tap --no-cov --timeout=150 --jobs=4 test/*.js test/reporters/*.js",
"test": "xo && flow check && nyc tap --no-cov --timeout=150 --jobs=4 test/*.js test/reporters/*.js",
"test-win": "tap --no-cov --reporter=classic --timeout=150 --jobs=4 test/*.js test/reporters/*.js",
"visual": "node test/visual/run-visual-tests.js",
"prepublish": "npm run make-ts",
Expand Down Expand Up @@ -167,6 +167,7 @@
"coveralls": "^2.11.4",
"delay": "^1.3.0",
"execa": "^0.6.0",
"flow-bin": "^0.38.0",
"get-stream": "^3.0.0",
"git-branch": "^0.3.0",
"has-ansi": "^2.0.0",
Expand Down
53 changes: 53 additions & 0 deletions test/flow-types/regression-1114.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* @flow */

const test = require('../../');

test('Named test', t => {
t.pass('Success');
// $ExpectError: Unknown method "unknownAssertion"
t.unknownAssertion('Whoops');
const context = t.context;
// $ExpectError: Unknown method "end"
t.end();
});

test(t => {
t.pass('Success');
// $ExpectError: Unknown method "unknownAssertion"
t.unknownAssertion('Whoops');
const context = t.context;
// $ExpectError: Unknown method "end"
t.end();
});

test.cb(t => {
t.pass('Success');
t.end();
});

test.beforeEach(t => {
// $ExpectError: Unknown property "context"
const context = t.context;
})

function macro(t, input, expected) {
t.is(eval(input), expected);
}
macro.title = (title, input, expected) => title || input;

function macro2(t, input, expected) {
t.is(eval(input), expected);
}

test('2 + 2 === 4', macro, '2 + 2', 4);
test(macro, '2 * 3', 6);

test('2 + 2 === 4', [macro, macro2], '2 + 2', 4);
test([macro, macro2], '2 * 3', 6);

function macroBadTitle(t, input, expected) {
t.is(eval(input), expected);
}
macroBadTitle.title = 'Not a function';
// $ExpectError: Macro "title" is not a function
test('2 + 2 === 4', macroBadTitle, '2 + 2', 4);
19 changes: 19 additions & 0 deletions test/flow-types/regression-1148.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* @flow */

const test = require('../../');

test(t => {
t.throws(() => { throw new Error(); });
t.throws(Promise.reject(new Error()));

t.notThrows(() => { return; });
t.notThrows(Promise.resolve('Success'));

const error = t.throws(() => { throw new Error(); });
const message: string = error.message;

const promise = t.throws(Promise.reject(new Error()));
promise.then(error => {
const message: string = error.message;
})
});