istanbul

How to cover React jsx files in Istanbul?

我是研究僧i 提交于 2019-12-04 16:34:36
问题 I'm trying to integrate my existing test processes to now include React, but am struggling on the code coverage part. I've been able to get my unit tests working fine by following this project/tutorial - https://github.com/danvk/mocha-react - http://www.hammerlab.org/2015/02/14/testing-react-web-apps-with-mocha/ I've been using Istanbul to cover my node code and it's working pretty well. However, I'm having trouble getting it to cover the jsx files that I'm using in my tests. Here's an

Code coverage on JSX tests with Istanbul

好久不见. 提交于 2019-12-04 05:42:21
I am trying to instrument my code to get some coverage up and running, but something is slipping through my fingers. I launch istanbul with: node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha -- -u exports -R spec And my mocha.opts looks like this: app/assets/javascripts/components/**/*-mocha.jsx --compilers jsx:mocha/compiler.js Everything seems to run fine (the tests run, at least), but the only coverage that I get is on the files used to compile the JSX to JavaScript (used in compiler.js compiler.js 100% jsx-stub-transform.js 65% Terribly useful... Any ideas? Jeff Fairley I

getting nyc/istanbul coverage report to work with typescript

做~自己de王妃 提交于 2019-12-04 02:28:54
I'm struggling to get proper coverage with nyc/istanbul for my typescript/mocha/gulp project. I've tried a number of approaches, some of them seem to be unable to use source maps and other fails due to ts-node / tsc errors. My current setup is: nyc relevant config in package.json "scripts": { "test:coverage": "nyc npm run test:unit", "test:unit": "gulp mocha" } "nyc": { "check-coverage": true, "all": true, "extension": [ ".js", ".jsx", ".ts", ".tsx" ], "include": [ "src/**/!(*.test.*).[tj]s?(x)" ], "reporter": [ "html", "lcov", "text", "text-summary" ], "report-dir": "docs/reports/coverage" }

Istanbul nyc to exclude test files

折月煮酒 提交于 2019-12-03 23:37:16
I'm currently getting my test files in the final coverage. That's probably because they sit alongside my components instead of having their own test folder. How can I exclude these from the coverage? I have installed istanbul and nyc and I'm using mocha . My script looks like: "test": "nyc --reporter=html mocha tools/testSetup.js app/**/*.spec.js || true" Right, after some digging I've managed to get this working. I've added "nyc": { "include": "app", - only looks in the app folder "exclude": "**/*.spec.js" } to my package.json. Since I'm using webpack I'll probably try and find a way of

Ember CLI and code coverage

家住魔仙堡 提交于 2019-12-03 16:08:52
问题 Has anyone managed to get code coverage working with an Ember CLI project? I've tried using blanket.js and istanbul, as have others here, here and here, neither with any success. I've managed to get each to actually produce a coverage report but the report either says 0% (istanbul) or 100% (blanket.js), and there's no way the current tests provide 100% coverage. The built project JavaScript file that Ember CLI produces contains all of the project's source files with each file's contents being

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

帅比萌擦擦* 提交于 2019-12-03 15:16:48
问题 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 │ ├──

Minimal code to use Istanbul programmatically

*爱你&永不变心* 提交于 2019-12-03 14:35:40
I want to execute the command istanbul cover node_modules/mocha/bin/_mocha dist/test using the Istanbul programmatic API. But the docs don't say much about it, besides that everything is possible and linking to the enormous API documentation. I couldn't find any short example on the internet. I do not want to spawn a child process or use another module from NPM. I know how to run Mocha programmatically without coverage, so that is not the problem. I figured out one way to do this, but it isn't too pretty. If you eval (I know!) the instrumented code, Istanbul writes the coverage object to the

Code Coverage for Typescript using karma-jasmine and istanbul

*爱你&永不变心* 提交于 2019-12-03 12:23:45
问题 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

Webpack Karma Istanbul Remapping for TypeScript

送分小仙女□ 提交于 2019-12-03 06:05:20
I'm developing a client-side app and I'm having trouble with creating the right Karma configs. Right now, I have my setup as follows: Webpack: Using ts-loader, compiles TypeScript, assets etc. Karma: Using the webpack plugin, loads the Webpack config (which uses ts-loader), then runs all unit tests with Jasmine + PhantomJS The unit tests all run fine, but I haven't figured out a way to handle the webpack istanbul remapping. Karma-webpacks seems to not be generating source maps to allow the remapping to happen. Any pointers would be appreciated! Karma Config: var webpackConfig = require(".

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');