From 0374b6b65c9aef5a9477f2350263d7a86b5414e7 Mon Sep 17 00:00:00 2001 From: Bruno Dias Date: Thu, 15 Jun 2017 16:30:10 -0300 Subject: [PATCH] [chore] update makefile to run coverage. --- .travis.yml | 2 -- Makefile | 39 +++++++++++++++++++++++++-------------- karma.conf.js | 12 ++++++++---- package.json | 2 +- specs/Modal.spec.js | 3 --- webpack.test.config.js | 3 +-- 6 files changed, 35 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5497a21f..8635d814 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,5 @@ node_js: before_script: - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start -after_success: - - cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js script: - make tests-ci diff --git a/Makefile b/Makefile index 78048f7f..567d8227 100644 --- a/Makefile +++ b/Makefile @@ -2,27 +2,32 @@ NODE=$(shell which node) NPM=$(shell which npm) YARN=$(shell which yarn) JQ=$(shell which jq) +COVERALLS=./node_modules/coveralls/bin/coveralls.js REMOTE="git@github.com:reactjs/react-modal" VERSION=$(shell jq ".version" package.json) +COVERAGE?=true + help: info @echo @echo "Current version: $(VERSION)" @echo @echo "List of commands:" @echo - @echo " make info - display node, npm and yarn versions..." - @echo " make deps - install all dependencies." - @echo " make serve - start the server." - @echo " make tests - run tests." - @echo " make lint - run lint." - @echo " make docs - build and serve the docs." - @echo " make build - build project artifacts." - @echo " make publish - build and publish version on npm." - @echo " make publish-docs - build the docs and publish to gh-pages." - @echo " make publish-all - publish version and docs." + @echo " make info - display node, npm and yarn versions..." + @echo " make deps - install all dependencies." + @echo " make serve - start the server." + @echo " make tests - run tests." + @echo " make tests-single-run - run tests (used by continuous integration)." + @echo " make coveralls - show coveralls." + @echo " make lint - run lint." + @echo " make docs - build and serve the docs." + @echo " make build - build project artifacts." + @echo " make publish - build and publish version on npm." + @echo " make publish-docs - build the docs and publish to gh-pages." + @echo " make publish-all - publish version and docs." info: @echo node version: `$(NODE) --version` "($(NODE))" @@ -46,9 +51,15 @@ serve: tests: @npm run test -tests-ci: +tests-single-run: @npm run test -- --single-run +coveralls: + -cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js 2>/dev/null + +tests-ci: clean lint + @COVERAGE=$(COVERAGE) make tests-single-run coveralls + lint: @npm run lint @@ -91,9 +102,6 @@ publish-version: release-commit release-tag publish-finished: clean -clean: - @rm -rf .version .branch - pre-publish: clean .branch .version deps-project tests-ci build publish: pre-publish publish-version publish-finished @@ -111,3 +119,6 @@ publish-docs: deps-docs build-docs cd .. publish-all: publish publish-docs + +clean: + @rm -rf .version .branch ./coverage/* diff --git a/karma.conf.js b/karma.conf.js index f49914cd..023f7cab 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,3 +1,5 @@ +const browsers = [process.env.CONTINUOUS_INTEGRATION ? 'Firefox' : 'Chrome']; + module.exports = function(config) { config.set({ @@ -10,7 +12,7 @@ module.exports = function(config) { ], preprocessors: { - 'specs/spec_index.js': [ 'webpack', 'sourcemap' ] + 'specs/spec_index.js': ['webpack', 'sourcemap'] }, webpack: require('./webpack.test.config'), @@ -27,7 +29,8 @@ module.exports = function(config) { coverageReporter: { type : 'lcov', - dir : 'coverage/' + dir : 'coverage/', + subdir: '.' }, port: 9876, @@ -38,9 +41,10 @@ module.exports = function(config) { autoWatch: true, - browsers: [ (process.env.CONTINUOUS_INTEGRATION) ? 'Firefox' : 'Chrome' ], + browsers, - captureTimeout: 60000, + // Increase timeouts to prevent the issue with disconnected tests (https://goo.gl/nstA69) + captureTimeout: 4 * 60 * 1000, singleRun: (process.env.CONTINUOUS_INTEGRATION) }); diff --git a/package.json b/package.json index eb3faa5b..df2eac89 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "scripts": { "start": "./node_modules/.bin/webpack-dev-server --inline --host 127.0.0.1 --content-base examples/", "test": "cross-env NODE_ENV=test karma start", - "test:full": "npm-run-all -p 'test -- --single-run' lint", "lint": "eslint lib/" }, "authors": [ @@ -30,6 +29,7 @@ "babel-preset-react": "^6.5.0", "babel-preset-stage-2": "^6.24.1", "codeclimate-test-reporter": "^0.4.0", + "coveralls": "^2.13.1", "cross-env": "^5.0.1", "envify": "^3.4.1", "eslint": "^3.9.1", diff --git a/specs/Modal.spec.js b/specs/Modal.spec.js index 8e5ffd66..4309b47a 100644 --- a/specs/Modal.spec.js +++ b/specs/Modal.spec.js @@ -14,9 +14,6 @@ import { renderModal, unmountModal, emptyDOM } from './helper'; -import './Modal.events.spec'; -import './Modal.style.spec'; - describe('State', () => { afterEach('check if test cleaned up rendered modals', emptyDOM); diff --git a/webpack.test.config.js b/webpack.test.config.js index 6a416857..9639e227 100644 --- a/webpack.test.config.js +++ b/webpack.test.config.js @@ -1,14 +1,13 @@ const path = require('path'); const commonConfig = require('./webpack.config'); - commonConfig.plugins = []; commonConfig.entry = undefined; commonConfig.debug = true; commonConfig.devtool = 'inline-source-map'; if (process.env.CONTINUOUS_INTEGRATION || process.env.COVERAGE) { - commonConfig.module.postLoaders = commonConfig.module.postLoaders || [] + commonConfig.module.postLoaders = commonConfig.module.postLoaders || []; commonConfig.module.postLoaders.push({ test: /\.js$/, include: path.resolve('lib'),