Makes your code coverage a real time live source
Assuming that you use a Node code coverage tool like nyc to instrument your code
npm install --save-dev liverage nyc
Then load liverage
when running nyc
using script command in package.json
{
"scripts": {
"test": "nyc --require liverage node index.js"
}
}
Run npm test
and the process becomes a WebSocket server
(via ws) on default port 3032
(use variable PORT to control this).
There is a simple example included with this repository you can observe if you clone it
git clone git@github.com:bahmutov/liverage.git
cd liverage
npm run example-live
# starts a server, need a WebSocket client to observe
You can observe the live code coverage using any WebSocket client, for example a CycleJs one from liverage-client repo.
Currently liverage
collects and sends the messages for the last covered file, thus if the server
program is composed of multiple source files, the client will not be able to see them.
I have described the principle that allows liverage
to work in
Turning code coverage into live stream blog post.
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com> © 2016
License: MIT - do anything with the code, but don't blame me if it does not work.
Support: if you find any problems with this module, email / tweet / open issue on Github
Copyright (c) 2016 Gleb Bahmutov <gleb.bahmutov@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.