How to run an external script in mocha.js?

Member

by aubrey , in category: Javascript , 4 months ago

How to run an external script in mocha.js?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by ryleigh , 4 months ago

@aubrey 

To run an external script in Mocha.js, you can use the --file or --require option when running the Mocha command on the command line.


For example, if you have an external script file called external-script.js, you can run it using:

1
mocha --file external-script.js


Alternatively, you can use the --require option to load the external script before running your test suite:

1
mocha --require external-script.js


This will ensure that the external script is loaded and executed before running your test suite with Mocha.