@ganbarodigital/jasmine-ts

Execute jasmine with ts-node

Usage no npm install needed!

<script type="module">
  import ganbarodigitalJasmineTs from 'https://cdn.skypack.dev/@ganbarodigital/jasmine-ts';
</script>

README

jasmine-ts

NOTE: The original maintainer @svi3c seems to have disappeared. We've made a fork, so that we can fix issues that are stopping us from using jasmine-ts in our own projects.

Build Status

A simplification for running jasmine with ts-node.

Installation

npm i -D jasmine-ts

Usage

  • In your package.json file create a test script:

    {
      "scripts": {
        "test": "jasmine-ts \"path/to/specs/**/*.spec.ts\""
      }
    }
    
  • Initialize jasmine

    node_modules/.bin/jasmine-ts init
    

    Note: This module enables the configuration support of reporters. For example, if you want to use the jasmine-spec-reporter, which provides a nice output, you can add a reporters array to the jasmine.json file like this:

    {
      "reporters": [
        {
          "name": "jasmine-spec-reporter#SpecReporter",
          "options": {
            "displayStacktrace": "all"
          }
        }
      ]
    }
    

    If the reporters are not the default export of the module, you can reference another export by using the # separator.

  • Run the tests

    npm test
    

Running with istanbul coverage

You can use nyc to check your test coverage.

Example package.json:

{
  "scripts": {
    "test": "nyc  -r lcov -e .ts -x \"*.spec.ts\" jasmine-ts \"path/to/specs/**/*.spec.ts\""
  }
}

Note

You still need to install the typings for jasmine to make the typescript-compiler happy about your specs:

TypeScript 2:

npm i -D @types/jasmine

TypeScript 1:

typings i -DG dt~jasmine

Since 0.1.3 ts-node options are passed through to ts-node.