简体   繁体   中英

Preserve symbolic link in mocha js

In node, if you want to preserve symbolic link when you run a script only add the flag: node --preserve-symlinks index.js I think to use the same thing using mocha js for a test, but this not work, in docs, I can't found how to use this flag or alternative flag for testing purposes and keep the symbolic links to another repository in node_modules.

I try this to, without success:

"test": "set NODE_OPTIONS=--preserve-symlinks & mocha --recursive --exit",
"test": "mocha --preserve-symlinks --recursive --exit",

What can I do?

I had the same problem, this was my original script:

   "test:unit": "mocha --opts mocha.opts --timeout 30000 \"test/unit/**/*.js\"",

changed it to this:

   "test:unit": "node --preserve-symlinks ./node_modules/.bin/mocha --opts mocha.opts --timeout 30000 \"test/unit/**/*.js\""

And it works: :)

Without more explanation of your project structure I cannot say why --preserve-symlink is not working for you, but the following command will run Mocha while preserving the symlinks:

mocha --preserve-symlinks --exit

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