Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Jasmine tests in watch mode for TypeScript

I have a Node.js app using TypeScript and now I want Jasmine to run tests automatically each time I make changes in .ts files. So I'm just trying to find an appropriate command to be run as npm test in command line or a package that can watch my .ts files compile them on changes and run jasmine. Does anybody know a solution for it?

like image 341
Alex Myznikov Avatar asked Feb 05 '23 02:02

Alex Myznikov


1 Answers

The easiest way I found is

installing dependencies: npm install --save-dev jasmine-ts nodemon

initializing jasmine: node_modules/.bin/jasmine-ts init

In the package.json:

"scripts": {
    "test": "nodemon --ext ts --exec 'jasmine-ts \"src/**/*.spec.ts\"'"
}

Edit: the above solution doesn't work as of the 11th of Apr, 2019. I published a modified working example at https://github.com/erosb/ts-node-jasmine-example

like image 118
erosb Avatar answered Feb 06 '23 16:02

erosb