Search code examples
javascriptnode.jstypescriptjasmine

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?


Solution

  • 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