mirror of https://github.com/lukechilds/ava.git
Browse Source
Closes #1224. This adds flow-bin, adds it to the test running script, and adds some regression tests based on prior issues. In an immediate proof of value (and proof of my own prior sloppiness) it spotted an issue that #1219 sought to fix and did not do so. Fix included along with test.use-hullabaloo
Lee Byron
8 years ago
committed by
Juan Soto
5 changed files with 83 additions and 3 deletions
@ -0,0 +1,7 @@ |
|||
[ignore] |
|||
<PROJECT_ROOT>/node_modules/.* |
|||
<PROJECT_ROOT>/.*\.js$ |
|||
|
|||
[options] |
|||
emoji=true |
|||
suppress_comment=\\(.\\|\n\\)*\\$ExpectError |
@ -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); |
@ -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; |
|||
}) |
|||
}); |
Loading…
Reference in new issue