karma-coverage

Getting Karma code coverage for pre-transpilation source code

独自空忆成欢 提交于 2019-12-03 09:47:38
问题 I'm using Karma to run tests, webpack to bundle files, and babel for es6 -> es5 transpilation. I've got the tests running and code coverage being generated, but the code coverage numbers are for the source files after being transpiled. Is there anyway to get code coverage for the original source files instead? I tried using the sourcemap preprocessor but it didn't seem to do anything. Do I need to add that to the webpack config somewhere? karma.conf.js config.set({ browsers: ['Chrome'], //run

How to measure common coverage for Polymer components + .js files?

三世轮回 提交于 2019-12-03 08:49:43
How to measure common coverage for Polymer components with all .js files in solution (for non-component tests QUnit is used)? I tried karma-coverage , but it works only for .js files. For Polymer, you would normally use web-component-tester (WCT) to test your components, and the web-component-tester-istanbul plugin for code coverage. You'd configure wct.conf.json in the root of your project with something like this: { "suites": [ "test/components/my-view1/my-view1.html" ], "plugins": { "istanbul": { "dir": "./build/coverage", "reporters": [ "text-summary", "lcov" ], "include": [ "*.js", "*

How to do code coverage with karma, typescript, and browserify

穿精又带淫゛_ 提交于 2019-12-03 05:53:47
How do you setup karma test runner to generate code coverage reports of a typescript project? Given the following folder structure and karma.conf.js file I'm already using karma to run my tests written in TypeScript. I already fiddled around with karma-coverage and remap-istanbul but without any luck yet. If possible I'd like to do it without any additional npm scripts . . ├── karma.conf.js ├── package.json ├── src │ └── add.ts ├── test │ └── addSpec.ts ├── tsconfig.json ├── typings │ ├── globals │ └── index.d.ts └── typings.json karma.conf.js var istanbul = require('browserify-istanbul');

Code Coverage for Typescript using karma-jasmine and istanbul

走远了吗. 提交于 2019-12-03 02:54:19
I am trying to get the Code Coverage for my typescript Code in karma framework using Istanbul in karma.conf typescript files are included and by karma typescript-preprocessor we able to do unit testing and code coverage of the typescript code but Code coverage report come for trans piled JavaScript code How can I get the coverage report for typescript code? Here is my karma.conf file. module.exports = function(config) { config.set({ // base path, that will be used to resolve files and exclude basePath: '', // frameworks to use frameworks: ['jasmine'], preprocessors: { 'src/**/*.ts': [

Getting Karma code coverage for pre-transpilation source code

倖福魔咒の 提交于 2019-12-03 00:21:19
I'm using Karma to run tests, webpack to bundle files, and babel for es6 -> es5 transpilation. I've got the tests running and code coverage being generated, but the code coverage numbers are for the source files after being transpiled. Is there anyway to get code coverage for the original source files instead? I tried using the sourcemap preprocessor but it didn't seem to do anything. Do I need to add that to the webpack config somewhere? karma.conf.js config.set({ browsers: ['Chrome'], //run in Chrome files: [ 'src/**/*-test.js' ], frameworks: ['mocha'], //use the mocha test framework plugins

How to change the format of the LCOV report executed by Karma?

我们两清 提交于 2019-11-30 01:17:46
I've configured Karma to report the coverage of my JavaScript code. Here is the part of the configuration in the karma.conf.js file: coverageReporter: { reporters: [ { type: 'html', dir: 'build/karma/coverage' }, { type: 'lcov', dir: 'build/karma/coverage', subdir: '.' }, { type: 'cobertura', dir: 'build/karma/coverage' } ] }, My lcov.info file has the following format: TN: SF:./app/scripts/app.js FN:16,(anonymous_1) FN:26,(anonymous_2) FNF:2 FNH:1 FNDA:1,(anonymous_1) FNDA:0,(anonymous_2) DA:2,1 DA:20,1 DA:29,0 DA:34,0 LF:4 LH:2 BRF:0 BRH:0 end_of_record Unfortunately, the Sonarqube

SonarQube and Lcov report Could not resolve file paths

纵然是瞬间 提交于 2019-11-29 07:23:25
We are trying to make a SonarQube code coverage report for our angular application. We have used Karma to generate a code coverage report and import it into SonarQube analyzer. The SonarQube already has C# coverage for our project, now we want to add JavaScript code coverage as well. Teamcity calls, Karma and it creates a code coverage and put the lcov file and report files into src\Planning.Spa\Coverage\report folder. LCOV File TN: SF:E:/a03/work/bb52cb33e083fc9/src/Planning.Spa/Offer/app/app.component.js FN:5,(anonymous_1) FN:6,AppComponent FN:8,(anonymous_3) FN:9,(anonymous_4) Teamcity has

Testing error case with observables in services

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 07:28:10
Let's say I have a component that subscribes to a service function: export class Component { ... ngOnInit() { this.service.doStuff().subscribe( (data: IData) => { doThings(data); }, (error: Error) => console.error(error) ); }; }; The subscribe call takes two anonymous functions as parameters, I've managed to set up a working unit test for the data function but Karma won't accept coverage for the error one. I've tried spying on the console.error function, throwing an error and then expecting the spy to have been called but that doesn't quite do it. My unit test: spyOn(console,'error').and

Testing error case with observables in services

佐手、 提交于 2019-11-26 17:39:24
问题 Let's say I have a component that subscribes to a service function: export class Component { ... ngOnInit() { this.service.doStuff().subscribe( (data: IData) => { doThings(data); }, (error: Error) => console.error(error) ); }; }; The subscribe call takes two anonymous functions as parameters, I've managed to set up a working unit test for the data function but Karma won't accept coverage for the error one. I've tried spying on the console.error function, throwing an error and then expecting