Skip to content

Commit

Permalink
Add gulp unittest --coverage argument (chartjs#4075)
Browse files Browse the repository at this point in the history
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 chartjs#3256). Delete `thankyou.md` which has been merged into `README.md`.
  • Loading branch information
simonbrunel authored and roicos committed Aug 21, 2017
1 parent 826ce3b commit 4ac523c
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 82 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ before_script:

script:
- gulp build
- gulp test
- gulp coverage
- gulp test --coverage
- gulp package
- gulp bower
- cat ./coverage/lcov.info | ./node_modules/.bin/coveralls
Expand Down
19 changes: 6 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,14 @@ You can find documentation at [www.chartjs.org/docs](http://www.chartjs.org/docs

## Contributing

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.
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).

For support using Chart.js, please post questions with the [`chartjs` tag on Stack Overflow](http://stackoverflow.com/questions/tagged/chartjs).
## Building
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).

## Building and Testing

To build, run `gulp build`.

To test, run `gulp test`.

To test against code standards, run `gulp lint`.

More information on building and testing can be found in [gulpfile.js](gulpfile.js).

Thanks to [BrowserStack](https://browserstack.com) for allowing our team to test on thousands of browsers.
## Thanks
- [BrowserStack](https://browserstack.com) for allowing our team to test on thousands of browsers.
- [@n8agrin](https://twitter.com/n8agrin) for the Twitter handle donation.

## License

Expand Down
5 changes: 0 additions & 5 deletions config.jshintrc

This file was deleted.

20 changes: 14 additions & 6 deletions docs/developers/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,34 @@ New contributions to the library are welcome, but we ask that you please follow
- Keep pull requests concise, and document new functionality in the relevant `.md` file.
- Consider whether your changes are useful for all users, or if creating a Chart.js plugin would be more appropriate.

# Building Chart.js
# Building and Testing

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

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:

```bash
npm install
npm install -g gulp
> npm install
> npm install -g gulp
```

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>.

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

```bash
gulp build
> gulp build // build Chart.js in ./dist
> gulp unittest // run tests from ./test/specs
> gulp unittest --watch // run tests and watch for source changes
> gulp unittest --coverage // run tests and generate coverage reports in ./coverage
> gulp lint // perform code linting (ESLint)
> gulp test // perform code linting and run unit tests
> gulp docs // build the documentation in ./dist/docs
```

# Bugs & issues
More information can be found in [gulpfile.js](https://github.com/chartjs/Chart.js/blob/master/gulpfile.js).

# Bugs and Issues

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.

12 changes: 3 additions & 9 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ var header = "/*!\n" +
gulp.task('bower', bowerTask);
gulp.task('build', buildTask);
gulp.task('package', packageTask);
gulp.task('coverage', coverageTask);
gulp.task('watch', watchTask);
gulp.task('lint', lintTask);
gulp.task('docs', docsTask);
Expand Down Expand Up @@ -202,14 +201,9 @@ function unittestTask(done) {
configFile: path.join(__dirname, 'karma.conf.js'),
singleRun: !argv.watch,
files: startTest(),
}, done).start();
}

function coverageTask(done) {
new karma.Server({
configFile: path.join(__dirname, 'karma.coverage.conf.js'),
files: startTest(),
singleRun: true,
args: {
coverage: !!argv.coverage
}
}, done).start();
}

Expand Down
15 changes: 15 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint camelcase: 0 */

module.exports = function(karma) {
var args = karma.args || {};
var config = {
browsers: ['Firefox'],
frameworks: ['browserify', 'jasmine'],
Expand Down Expand Up @@ -29,5 +30,19 @@ module.exports = function(karma) {
config.browsers.push('Chrome');
}

if (args.coverage) {
config.reporters.push('coverage');
config.browserify.transform = ['browserify-istanbul'];

// https://github.com/karma-runner/karma-coverage/blob/master/docs/configuration.md
config.coverageReporter = {
dir: 'coverage/',
reporters: [
{type: 'html', subdir: 'report-html'},
{type: 'lcovonly', subdir: '.', file: 'lcov.info'}
]
};
}

karma.set(config);
};
44 changes: 0 additions & 44 deletions karma.coverage.conf.js

This file was deleted.

3 changes: 0 additions & 3 deletions thankyou.md

This file was deleted.

0 comments on commit 4ac523c

Please sign in to comment.