简体   繁体   中英

mocha with ts-node create a folder ts-node-*

i am currently working with mocha on tests written in typescript.

here is my mocha.opts file

--require ts-node/register
--watch-extensions ts
--reporter nyan
test/**/*.test.ts

in my package.json i have:

"scripts": {
  "test": "NODE_ENV=test mocha"
}

and then I run the npm test

However, this command creates a folder ts-node-b04239ff3a39df9137e32efd559f1a2935cb in my root directory.

The strangest thing is that when I run my tests using mocha cli, this folder is not created.

NODE_ENV=test ./node_modules/.bin/mocha

I would like to know what this file is and how to make it no longer appear ?

The generated folder is the ts-node cache directory.

You can change the cache directory to different folder like /tmp/ using the --cacheDirectory option (or setting the TS_NODE_CACHE_DIRECTORY env)

https://github.com/TypeStrong/ts-node#cli-and-programmatic-options

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM