Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code coverage with tsify #200

Closed
iamolivinius opened this issue Aug 4, 2016 · 1 comment
Closed

Code coverage with tsify #200

iamolivinius opened this issue Aug 4, 2016 · 1 comment

Comments

@iamolivinius
Copy link

Not sure if this is the right place to file this issue but your project seems to me to be a common denominator.

My goal is to get code coverage reports of a typescript project. Therefore I use the karma test runner in the following configuration.

var istanbul = require('browserify-istanbul');
module.exports = function(config) {
  config.set({
    basePath: '',
    frameworks: ['browserify', 'mocha', 'chai', 'source-map-support'],
    files: [
      'test/**/*Spec.ts'
    ],
    exclude: [
    ],
    preprocessors: {
      'test/**/*Spec.ts': ['browserify']
    },
    browserify: {
      debug: true,
      transform: [istanbul()]
    },
    reporters: ['progress', 'coverage'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: true,
    concurrency: Infinity
  })
}

src/add.ts

export function add(a: number, b: number): number {
  if (a === 0)
    return b

  if (b === 0)
    return a

  return a + b
}

test/addSpec.ts

import {add} from '../src/add'
const expect = chai.expect

describe('test add module', () => {
  it('should add 2 numbers', () => {
    expect(add(1, 2)).to.be.equal(3)
  })
})

The metrics of the coverage report seem to be ok but the annotation in the "source file view" are a bit odd.

screenshot from 2016-08-05 00-10-16

My first guess is that something with the source maps went wrong due to the multiple transformations along the process.

I hope you can provide me any information or point me in the right direction to solve this issue.

Also I filed this as a question on stackoverflow earlier today: http://stackoverflow.com/questions/38764929/how-to-do-code-coverage-with-karma-typescript-and-browserify

@nikku
Copy link
Owner

nikku commented Jan 3, 2018

Closing this as WONT_FIX as this is I don't have sufficient knowledge on tsify + coverage setups to help you out on this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants