diff --git a/.travis.yml b/.travis.yml index 2df4a4cd7..d99266137 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/README.md b/README.md index daec17a46..4b0ab2884 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/config.jshintrc b/config.jshintrc deleted file mode 100644 index 00b42024f..000000000 --- a/config.jshintrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "node": true, - "unused": true, - "predef": [ "require", "module" ] -} \ No newline at end of file diff --git a/docs/developers/contributing.md b/docs/developers/contributing.md index 67c391db5..70908dd6d 100644 --- a/docs/developers/contributing.md +++ b/docs/developers/contributing.md @@ -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 gulp 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 gulp. -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 github.com/chartjs/Chart.js. If you could include a link to a simple jsbin or similar to demonstrate the issue, that'd be really helpful. diff --git a/gulpfile.js b/gulpfile.js index 785004b2c..884242f05 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -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); @@ -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(); } diff --git a/karma.conf.js b/karma.conf.js index 39e5ae61a..3ef7f49bf 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,6 +1,7 @@ /* eslint camelcase: 0 */ module.exports = function(karma) { + var args = karma.args || {}; var config = { browsers: ['Firefox'], frameworks: ['browserify', 'jasmine'], @@ -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); }; diff --git a/karma.coverage.conf.js b/karma.coverage.conf.js deleted file mode 100644 index 4975f1688..000000000 --- a/karma.coverage.conf.js +++ /dev/null @@ -1,44 +0,0 @@ -module.exports = function(config) { - var configuration = { - browsers: ['Firefox'], - frameworks: ['browserify', 'jasmine'], - reporters: ['progress', 'coverage'], - - preprocessors: { - './test/jasmine.index.js': ['browserify'], - './src/**/*.js': ['browserify'] - }, - - browserify: { - debug: true, - transform: [['browserify-istanbul', { - instrumenterConfig: { - embed: true - } - }]] - }, - - coverageReporter: { - dir: 'coverage/', - reporters: [ - { type: 'html', subdir: 'report-html' }, - { type: 'lcovonly', subdir: '.', file: 'lcov.info' } - ] - } - }; - - // If on the CI, use the CI chrome launcher - if (process.env.TRAVIS) { - configuration.browsers.push('Chrome_travis_ci'); - configuration.customLaunchers = { - Chrome_travis_ci: { - base: 'Chrome', - flags: ['--no-sandbox'] - } - }; - } else { - configuration.browsers.push('Chrome'); - } - - config.set(configuration); -}; \ No newline at end of file diff --git a/thankyou.md b/thankyou.md deleted file mode 100644 index 1300c2ab8..000000000 --- a/thankyou.md +++ /dev/null @@ -1,3 +0,0 @@ -## Thanks go out to: - -- **@n8agrin** - Twitter handle donation!