avajs / ava

Node.js test runner that lets you develop with confidence 🚀
MIT License
20.74k stars 1.41k forks source link

Can't import TypeScript module #1588

Closed HamedFathi closed 6 years ago

HamedFathi commented 6 years ago

We want to use avajs in our project but seems it can not import some pathes correctly

I imported a class with correct path. you can see the below picture. VS Code recognize it correctly.

err

but avajs can not

err1

Can anyone guide me why ?

novemberborn commented 6 years ago

Your src directory contains .ts files. By default AVA will be loading .js files instead. You could add ts-node/register to AVA's require configuration and it should work.

HamedFathi commented 6 years ago

@novemberborn

I am not familiar with ts-node/register Do you have a sample for this problem?

novemberborn commented 6 years ago

See https://www.npmjs.com/package/ts-node.

Configure the require option as shown in https://github.com/avajs/ava#configuration — but use ts-node/register instead of babel-register.