README
What is wut?
wut
is an extension that I'm hoping will overlay code coverage information and run unit tests specific to individual files. This will be my first VSCode extension and seems like a good opportunity to poke around a bit. The code is hosted on github if you want to contribute: https://github.com/entrocode/wut
Config Example (Workspace settings)
{
"wut.lcov":"./test-results/coverage/PhantomJS 1.9.8 (Mac OS X 0.0.0)/lcov.info",
"wut.runOnSave": true,
"wut.gruntTask": "one"
}
Example Project Gruntfile
Note: Probably a better way to do this, and I realize src
takes lists... this is "quick and dirty"
module.exports = function (grunt) {
function getKarmaConfig(testFolder, testTarget) {
return {
options: {
configFile: 'test/karma-conf.js'
},
one: {
singleRun: true,
files: [
// include relevant Angular files and libs
{ src: 'app/lib/angular/angular.js' },
{ src: 'test/lib/angular-mocks.js' },
// include JS files
{ src: ['!app/js/**/*.spec.js', 'app/js/**/*.js'] },
{ src: 'app/js/app.js' },
// include unit test specs
{ src: testTarget ? testTarget : testFolder ? testFolder + '*.spec.js' : 'app/js/**/*.spec.js' }
]
}
};
};
grunt.initConfig({
karma: getKarmaConfig(),
...
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-protractor-runner');
grunt.loadNpmTasks('grunt-run');
...
var target = grunt.option('target') || '';
var folder = grunt.option('folder') || '';
grunt.registerTask('one', function () {
grunt.config.set('karma', getKarmaConfig(folder, target));
grunt.task.run(['karma:one:start']);
});
};
TODO
Save lcov.info path in config
Import LCOV
Compare LCOV to active window
Parse LCOV by file and line
Display icon in gutter and highlight rows
Output to console what problems are
Add Warnings
Hover text
Run tests from extension command
Activate extension (or register some things) on workspace open? (I check for .js extension, that way I don't un-necessarily load the extension)
Run command on file save
Run tests on file save
Run tests for individual file (see example Gruntfile.js above)
Run tests for individual file on file save (for folder that the file is in)
Parse test output for failing file / test
Highlight failing tests in spec
Display expected info in spec hovertext at beginning of line and in console
- ? Save a coverage (json?) file (with percents)
- ? On file save re-calculate coverage and show the delta
References