Skip to content

Commit

Permalink
Merge pull request #11111 from DanielRuf/tests/use-husky
Browse files Browse the repository at this point in the history
tests: use husky to run tests before commits and pushes
  • Loading branch information
ncoden authored Apr 2, 2018
2 parents fa99515 + 073d0f2 commit 70aecf9
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 79 deletions.
178 changes: 106 additions & 72 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@
"start": "gulp",
"test": "npm run test:sass && npm run test:javascript:units",
"test:ci": "npm run test:sass && npm run test:javascript:ci",
"test:sass": "mocha test/sass/test_sass.js",
"test:javascript:transpile": "gulp sass:foundation && gulp test:transpile-js",
"test:sass": "mocha test/sass/test_sass.js --colors",
"test:javascript:transpile": "gulp sass:foundation --color && gulp test:transpile-js --color",
"test:javascript:units": "npm run test:javascript:transpile && mocha-headless-chrome -a ignore-resource-errors -f test/javascript/index.html",
"test:javascript:browserstack": "npm run test:javascript:transpile && browserstack-runner",
"test:javascript:ci": "npm run test:javascript:transpile && mocha-headless-chrome -a ignore-resource-errors -f test/javascript/index.html && browserstack-runner",
"test:visual": "gulp test",
"deploy": "gulp deploy",
"deploy:prep": "gulp deploy:prep",
"deploy:docs": "gulp deploy:docs",
"deploy:beta": "gulp deploy:beta"
"test:visual": "gulp test --color",
"deploy": "gulp deploy --color",
"deploy:prep": "gulp deploy:prep --color",
"deploy:docs": "gulp deploy:docs --color",
"deploy:beta": "gulp deploy:beta --color",
"precommit": "node ./script/husky-precommit.js --color",
"prepush": "node ./script/husky-prepush.js --color"
},
"dependencies": {
"jquery": ">=3.0.0",
Expand Down Expand Up @@ -76,6 +78,7 @@
"gulp-sourcemaps": "^2.6.0",
"gulp-uglify": "^2.1.2",
"gulp-zip": "^3.2.0",
"husky": "^0.14.3",
"inquirer": "^2.0.0",
"is-empty-object": "^1.1.1",
"js-yaml": "^3.8.4",
Expand Down
22 changes: 22 additions & 0 deletions script/husky-precommit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const chalk = require('chalk')
const spawn = require('child_process').spawn

console.log(chalk.yellow('🐶 Checking tests before committing with Husky...'))

const child = spawn('npm run test', [], { shell: true })

child.stdout.on('data', function (data) {
process.stdout.write(data)
})

child.on('exit', function (code) {
if(code === 0){
console.log(chalk.yellow('🐶 ✓ Tests run well, we can commit...'))
} else {
console.log(chalk.yellow('🐶 ✗ Tests are failing, please fix them before committing.'))
}
})

child.on('error', function (err) {
console.log(chalk.red(err))
})
22 changes: 22 additions & 0 deletions script/husky-prepush.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const chalk = require('chalk')
const spawn = require('child_process').spawn

console.log(chalk.yellow('🐶 Checking tests before pushing with Husky...'))

const child = spawn('npm run test', [], { shell: true })

child.stdout.on('data', function (data) {
process.stdout.write(data)
})

child.on('exit', function (code) {
if(code === 0){
console.log(chalk.yellow('🐶 ✓ Tests run well, we can push...'))
} else {
console.log(chalk.yellow('🐶 ✗ Tests are failing, please fix them before pushing.'))
}
})

child.on('error', function (err) {
console.log(chalk.red(err))
})

0 comments on commit 70aecf9

Please sign in to comment.