Skip to content

Commit dfdeae6

Browse files
authored
Merge pull request #1 from philschatz/refactor
Refactor to use SourceMaps and update packages
2 parents 6e5d038 + 0dd1c9d commit dfdeae6

15 files changed

Lines changed: 632 additions & 618 deletions

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
bower_components/
2-
node_modules/
1+
/node_modules/
32

43
# Files generated by README.md examples
5-
/css.lcov
4+
/css.lcov
5+
6+
# HTML Coverage Report
7+
/coverage/

Gruntfile.coffee

Lines changed: 0 additions & 53 deletions
This file was deleted.

README.md

Lines changed: 19 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,11 @@
11
# CSS Coverage!
22

3-
Generates coverage information of your CSS (or LESS) files using the command line or in browser/GruntJS unit tests.
4-
5-
By hooking into [BlanketJS](http://blanketjs.org) you can use this with Jasmine, Mocha, QUnit, Coveralls, and tools like [grunt-blanket-mocha](https://github.com/ModelN/grunt-blanket-mocha).
3+
Generates coverage information of your CSS files and creates reports using the optional source maps.
64

75
## How is this different from other CSS coverage tools?
86

9-
Code coverage tools use Unit Tests to "exercise" the code and show you what is not tested; this project hooks into those same tools and gives you CSS coverage information for free!
10-
11-
It also:
12-
13-
- gives coverage information on your source _LESS_ files, not just the compiled CSS file
14-
- also instruments files loaded via the RequireJS `less!` plugin (if used)
15-
- provides a command line script to run against individual test files or pages hosted on a website
16-
17-
**TODO:** Coverage currently runs after every test but there will be a function you can call in the middle of a test
18-
19-
## Can I see it?
20-
21-
Check out the in-browser [mocha demo](http://philschatz.github.io/css-coverage.js/test/mocha-demo)! (see _"blanket.js results"_ for the CSS coverage)
22-
23-
### Screenshot
24-
25-
![image](https://f.cloud.github.com/assets/253202/2317474/4856dbea-a34e-11e3-92ae-70f53672cb93.png)
7+
- gives coverage information on your source files (SASS/LESS/Stylus/etc), not just the compiled CSS file
8+
- provides a command line script to run against individual test files
269

2710

2811
## What can I do with `css-coverage`?
@@ -39,49 +22,28 @@ You can use the command line version to:
3922
You can also generate LCOV Files for Coveralls or just HTML reports:
4023

4124
# Run CSS Coverage and generate a LCOV report (with verbose output)
42-
node ./bin/css-coverage -v -s ./test/test.css -h ./test/test.html -l ./css.lcov
25+
css-coverage --css ./test/test.css --html ./test/test.html --lcov ./css.lcov
4326

4427
# Optionally Generate an HTML report
4528
genhtml ./css.lcov --output-directory ./coverage
4629

4730

48-
### Can I test Coverage of an entire Website?
49-
50-
You can generate CSS coverage of a website by providing a URL instead of a local file in the `-h` command line argument.
51-
52-
**TODO:** Write an example using [CasperJS](http://casperjs.org)
53-
54-
55-
## Can I run it with mocha, Jasmine, QUnit?
56-
57-
Yep! It integrates with [BlanketJS](http://blanketjs.org/) so you can see LESS/CSS coverage as well as JavaScript coverage.
58-
59-
All you need to do is add the following to your test harness HTML file (usually `test/index.html`:
60-
61-
1. include `<script src=".../css-polyfills/dist/css-polyfills.js"></script>`
62-
2. include `<script src="./src/css-coverage.js"></script>` after BlanketJS
63-
3. include `<link rel="stylesheet/coverage" href="path/to/css/file.[less|css]">` to specify which CSS files to cover
64-
65-
See the [mocha demo](http://philschatz.github.io/css-coverage.js/test/mocha-demo) for an example and <test/mocha-demo/index.html> for the code.
66-
67-
68-
## How do I install it?
69-
70-
You can install locally or globally. Installing globally will give you access to `css-coverage` from the command line.
71-
72-
Locally (on the command line or in conjunction with [BlanketJS](http://blanketjs.org/)):
73-
74-
npm install
75-
# Run CSS Coverage on the command line
76-
./bin/css-coverage -s ./test/test.css -h ./test/test.html
77-
78-
Globally (on the command line):
31+
## Commandline Options
7932

80-
npm install -g .
81-
# Run CSS Coverage
82-
css-coverage -s ./test/test.css -h ./test/test.html
33+
```txt
34+
Usage: css-coverage [options]
8335
36+
Generate coverage info for a CSS file against an HTML file.
37+
This supports loading sourcemaps by using the sourceMappingURL=FILENAME.map CSS comment
8438
85-
## How does this work?
39+
Options:
8640
87-
This project uses <http://philschatz.com/css-polyfills.js/>.
41+
-h, --help output usage information
42+
--html [path/to/file.html] path to a local HTML file
43+
--css [path/to/file.css] path to a local CSS file
44+
--lcov [path/to/output.lcov] the LCOV output file
45+
--verbose verbose/debugging output
46+
--ignore-source-map disable loading the sourcemap if one is found
47+
--cover-declarations try to cover CSS declarations as well as selectors
48+
(best-effort, difficult with sourcemaps)
49+
```

0 commit comments

Comments
 (0)