mirror of https://github.com/lukechilds/ava.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.4 KiB
1.4 KiB
TypeScript
Translations: Español, Français, Italiano, Русский, 简体中文
AVA comes bundled with a TypeScript definition file. This allows developers to leverage TypeScript for writing tests.
Setup
First install TypeScript.
$ npm install --save-dev typescript
Create a tsconfig.json
file. This file specifies the compiler options required to compile the project or the test file.
{
"compilerOptions": {
"module": "commonjs",
"target": "es2015"
}
}
Add a test
script in the package.json
file. It will compile the project first and then run AVA.
{
"scripts": {
"test": "tsc && ava"
}
}
Add tests
Create a test.ts
file.
import test from 'ava';
async function fn() {
return Promise.resolve('foo');
}
test(async (t) => {
t.is(await fn(), 'foo');
});
Execute the tests
$ npm test