Skip to content

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.

Floss v4+

Register ts-node using the --require flag.

floss -p test/index.ts --require ts-node/register

Floss v3 and before

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
Clone this wiki locally