Skip to content

Commit e3f3b89

Browse files
authored
Add gulp unittest --coverage argument (#4075)
Coverage data are now generated by running `gulp unittest` with the `--coverage` argument: unit tests are then executed a single time on Travis. The gulp `coverage` task has been removed and `karma.coverage.conf.ci.js` merged into `karma.conf.ci.js`. Update documentation with gulp commands (and remove them from `README.md`) and remove unused `config.jshintrc` (oversight from #3256). Delete `thankyou.md` which has been merged into `README.md`.
1 parent 90d458a commit e3f3b89

File tree

8 files changed

+39
-82
lines changed

8 files changed

+39
-82
lines changed

.travis.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ before_script:
1212

1313
script:
1414
- gulp build
15-
- gulp test
16-
- gulp coverage
15+
- gulp test --coverage
1716
- gulp package
1817
- gulp bower
1918
- cat ./coverage/lcov.info | ./node_modules/.bin/coveralls

README.md

+6-13
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,14 @@ You can find documentation at [www.chartjs.org/docs](http://www.chartjs.org/docs
3333

3434
## Contributing
3535

36-
Before submitting an issue or a pull request to the project, please take a moment to look over the [contributing guidelines](https://github.com/chartjs/Chart.js/blob/master/CONTRIBUTING.md) first.
36+
Before submitting an issue or a pull request, please take a moment to look over the [contributing guidelines](https://github.com/chartjs/Chart.js/blob/master/CONTRIBUTING.md) first. For support using Chart.js, please post questions with the [`chartjs` tag on Stack Overflow](http://stackoverflow.com/questions/tagged/chartjs).
3737

38-
For support using Chart.js, please post questions with the [`chartjs` tag on Stack Overflow](http://stackoverflow.com/questions/tagged/chartjs).
38+
## Building
39+
Instructions on building and testing Chart.js can be found in [the documentation](https://github.com/chartjs/Chart.js/blob/master/docs/developers/contributing.md#building-and-testing).
3940

40-
## Building and Testing
41-
42-
To build, run `gulp build`.
43-
44-
To test, run `gulp test`.
45-
46-
To test against code standards, run `gulp lint`.
47-
48-
More information on building and testing can be found in [gulpfile.js](gulpfile.js).
49-
50-
Thanks to [BrowserStack](https://browserstack.com) for allowing our team to test on thousands of browsers.
41+
## Thanks
42+
- [BrowserStack](https://browserstack.com) for allowing our team to test on thousands of browsers.
43+
- [@n8agrin](https://twitter.com/n8agrin) for the Twitter handle donation.
5144

5245
## License
5346

config.jshintrc

-5
This file was deleted.

docs/developers/contributing.md

+14-6
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,34 @@ New contributions to the library are welcome, but we ask that you please follow
99
- Keep pull requests concise, and document new functionality in the relevant `.md` file.
1010
- Consider whether your changes are useful for all users, or if creating a Chart.js plugin would be more appropriate.
1111

12-
# Building Chart.js
12+
# Building and Testing
1313

1414
Chart.js uses <a href="http://gulpjs.com/" target="_blank">gulp</a> to build the library into a single JavaScript file.
1515

1616
Firstly, we need to ensure development dependencies are installed. With node and npm installed, after cloning the Chart.js repo to a local directory, and navigating to that directory in the command line, we can run the following:
1717

1818
```bash
19-
npm install
20-
npm install -g gulp
19+
> npm install
20+
> npm install -g gulp
2121
```
2222

2323
This will install the local development dependencies for Chart.js, along with a CLI for the JavaScript task runner <a href="http://gulpjs.com/" target="_blank">gulp</a>.
2424

25-
Now, we can run the `gulp build` task.
25+
The following commands are now available from the repository root:
2626

2727
```bash
28-
gulp build
28+
> gulp build // build Chart.js in ./dist
29+
> gulp unittest // run tests from ./test/specs
30+
> gulp unittest --watch // run tests and watch for source changes
31+
> gulp unittest --coverage // run tests and generate coverage reports in ./coverage
32+
> gulp lint // perform code linting (ESLint)
33+
> gulp test // perform code linting and run unit tests
34+
> gulp docs // build the documentation in ./dist/docs
2935
```
3036

31-
# Bugs & issues
37+
More information can be found in [gulpfile.js](https://github.com/chartjs/Chart.js/blob/master/gulpfile.js).
38+
39+
# Bugs and Issues
3240

3341
Please report these on the GitHub page - at <a href="https://github.com/chartjs/Chart.js" target="_blank">github.com/chartjs/Chart.js</a>. If you could include a link to a simple <a href="http://jsbin.com/" target="_blank">jsbin</a> or similar to demonstrate the issue, that'd be really helpful.
3442

gulpfile.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ var header = "/*!\n" +
3838
gulp.task('bower', bowerTask);
3939
gulp.task('build', buildTask);
4040
gulp.task('package', packageTask);
41-
gulp.task('coverage', coverageTask);
4241
gulp.task('watch', watchTask);
4342
gulp.task('lint', lintTask);
4443
gulp.task('docs', docsTask);
@@ -202,14 +201,9 @@ function unittestTask(done) {
202201
configFile: path.join(__dirname, 'karma.conf.js'),
203202
singleRun: !argv.watch,
204203
files: startTest(),
205-
}, done).start();
206-
}
207-
208-
function coverageTask(done) {
209-
new karma.Server({
210-
configFile: path.join(__dirname, 'karma.coverage.conf.js'),
211-
files: startTest(),
212-
singleRun: true,
204+
args: {
205+
coverage: !!argv.coverage
206+
}
213207
}, done).start();
214208
}
215209

karma.conf.js

+15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint camelcase: 0 */
22

33
module.exports = function(karma) {
4+
var args = karma.args || {};
45
var config = {
56
browsers: ['Firefox'],
67
frameworks: ['browserify', 'jasmine'],
@@ -29,5 +30,19 @@ module.exports = function(karma) {
2930
config.browsers.push('Chrome');
3031
}
3132

33+
if (args.coverage) {
34+
config.reporters.push('coverage');
35+
config.browserify.transform = ['browserify-istanbul'];
36+
37+
// https://github.com/karma-runner/karma-coverage/blob/master/docs/configuration.md
38+
config.coverageReporter = {
39+
dir: 'coverage/',
40+
reporters: [
41+
{type: 'html', subdir: 'report-html'},
42+
{type: 'lcovonly', subdir: '.', file: 'lcov.info'}
43+
]
44+
};
45+
}
46+
3247
karma.set(config);
3348
};

karma.coverage.conf.js

-44
This file was deleted.

thankyou.md

-3
This file was deleted.

0 commit comments

Comments
 (0)