Code Monkey home page Code Monkey logo

tscover's Introduction

TSCover - code coverage for TypeScript

Build Status

TSCover is a Typescript compiler that produces instrumented javascript used to collect code coverage information. Code coverage is saved in the form of LCOV files, JSON files or as an HTML report.

screenshot

Features

  • Works as a drop-in replacement for tsc. All tsc options work as expected.
  • Instruments .ts files during compilation. Does not require .map files.
  • Reports coverage as lcov.info, json files or as an html report.
  • Supports statement, branch and file coverage.

Usage

TSCover requires typescript library so first step is to make sure that typescript is installed globally. After that install tscover as the global library:

npm install -g typescript
npm install -g tscover

You can run tscover the same way that you would run tsc, all tsc options will work as expected. Or you can use tsconfig.json to specify compiler options:

tscover program.ts
tscover -p project/tsconfig.json

Run the program as you normally would and upon exit it will produce a coverage folder with lcov, json and html files in it.

Instrumented files

Normally tscover produces compiled javascript files only. However if you would like to see instrumented typescript files too pass --tscover-instrument flag:

tscover --tscover-instrument -p project/tsconfig.json

This will instruct the compiler to produce .ts.cover files that can be used for troubleshooting.

tscover's People

Contributors

durad avatar

Watchers

James Cloos avatar  avatar

tscover's Issues

No coverage reports generated

I don't seem to have any coverage generated, no coverage folder or any files.

I see that the TS files are transpiled into js and if I use the instrument flag I see the .coverage files generated but no coverage reports. Any suggestions what I could be missing ?

TypeError: source.getFullText is not a function

Node version: 9.4.0

Command used: tscover -p tsconfig.json

Not sure if this repo is maintained anymore, but running tscover to build our codebase (tsc works without issue) produces this stacktrace:

            hash.update(source.getFullText());
                               ^

TypeError: source.getFullText is not a function
    at Function.Util.calculateHash (/usr/local/lib/node_modules/tscover/build/util.js:15:32)
    at Object.ts.createProgram (/usr/local/lib/node_modules/tscover/build/project.js:46:38)
    at performCompilation (evalmachine.<anonymous>:73788:26)
    at Object.executeCommandLine (evalmachine.<anonymous>:73721:17)
    at ProjectInstrumenter.run (/usr/local/lib/node_modules/tscover/build/project.js:64:12)
    at Object.<anonymous> (/usr/local/lib/node_modules/tscover/build/index.js:4:37)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.