Warning. This note is about using mocha 6 and typescript. It will not work in mocha 5.x and lower and pure JS. But you can easily adapt it to your use cases.

How do you write tests for your typescript code? I prefer to write code and run test in one time in background on the second monitor. Mocha allows to do it with — watch option and you can add next script to your package.json:

Ok, now you can run it in the terminal and watch your tests:

npm run-script watch-tests

It looks good and pretty easy, but…


My pain

Default workflow RustDT (built upon Eclipse) is not very good for building small executables. When you learn new language, you want to build many small executables. And you don’t want to waste your time on IDE’s strange behavior:

  • Default project, created by Cargo, is “lib.” It is not executable.
  • Default run command is also for a library, and if you try to change it into cargo run you are not happy because IDE will run your new Exe file together with Cargo. If you change to build, IDE runs executable even if program build failed.
  • Import project doesn’t contain item…

Leonid Vygovskiy

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store