Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use with mocha & ts-node/register? #84

Open
bradennapier opened this issue Mar 11, 2020 · 4 comments
Open

How to use with mocha & ts-node/register? #84

bradennapier opened this issue Mar 11, 2020 · 4 comments

Comments

@bradennapier
Copy link

bradennapier commented Mar 11, 2020

Hey! Thanks for the work on this.

Wondering how we can use this with mocha? tsconfig-paths has its own tsconfig-paths/register to make this work

https://github.com/dividab/tsconfig-paths#with-mocha-and-ts-node

Basically with mocha we have to run mocha -r ts-node/register -- but that wouldnt have the compiler flag.

Would be worthwhile to have the ability to do it which looks like it'd prob just be something like:

// This is the same as ts-node/register except it sets the environment
// variable so that it uses the ttypescript compiler.  This variable
// could just be set in scripts but this convention makes it simpler.
process.env.TS_NODE_COMPILER = 'ttypescript';
// eslint-disable-next-line import/no-extraneous-dependencies
require('ts-node').register();
@bradennapier bradennapier changed the title How to use with mocha? has to use ts-node/register How to use with mocha/ts-node/register? Mar 11, 2020
@bradennapier bradennapier changed the title How to use with mocha/ts-node/register? How to use with mocha & ts-node/register? Mar 11, 2020
@cevek
Copy link
Owner

cevek commented Mar 31, 2020

register from ts-node has options

require('ts-node').register({
    compiler: 'ttypescript'
})

@bradennapier
Copy link
Author

I think the point I was making is that it would be nice to have a ttypescript/register or something similar - most have such an options such as ts-node/register or babel-node/register so that we can do this without having to use the programmatic api (which we could just use transformers at that point ;-)

@cevek
Copy link
Owner

cevek commented Apr 2, 2020

Good point. PR welcome :)

@millsp
Copy link

millsp commented Sep 22, 2020

TypeStrong/ts-node#4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants