Running TypeScript with Floss
Matt Karl edited this page Apr 7, 2021
·
4 revisions
The package ts-node can be used to run test that are authored with TypeScript.
Register ts-node using the --require
flag.
floss -p test/index.ts --require ts-node/register
The follow code is added first before loading any of your TypeScript tests, generally the start of test/index.js
.
// support requiring TypeScript files
require('ts-node').register({
project: __dirname + '/tsconfig.json', // or path to your tsconfig
transpileOnly: true, // speeds up imports
});
// require() tests here!
Then simply invoke floss normally:
floss -p test/index.js