Skip to content
This repository has been archived by the owner on Feb 2, 2019. It is now read-only.

Commit

Permalink
feat(develop): Add npm tdd and grunt tdd tasks
Browse files Browse the repository at this point in the history
Added a plugin to continue grunt process on karma on failure, used by
a new grunt task that just watches, compiles typescript, & runs karma,
The goal is helping contributers write unit tests, even a
test-driven workflow.

Also an `npm` script, `npm tdd` and a note about it in the docs.
  • Loading branch information
samuel.jones authored and justindujardin committed Jun 12, 2016
1 parent 414b67c commit 1b6ba0c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ And that's it! Now you run the Example app via `grunt serve` command, you can se
### Write some Tests

Don't forget to write tests about your component. Even if it's pretty awesome, it could help to avoid regression in the future.
Follow recommandations about [writing test in angular2][writing-test].
Follow recommandations about [writing test in angular2][writing-test].
There is an npm script for Test Driven Development: `npm run tdd`, which can be helpful.
When your tests pass and only after that, you can [propose a pull request](#how-to-contribute)


Expand Down
9 changes: 9 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ module.exports = function (grunt) {
'<%- sourceRoot %>/**/*.ts'
],
tasks: ['ts:source', 'rewrite-source-maps', 'notify:source']
},
karma: {
files: [
'<%- sourceRoot %>/**/*.ts'
],
tasks: ['karma']
}
},

Expand Down Expand Up @@ -194,6 +200,7 @@ module.exports = function (grunt) {
}
});

grunt.loadNpmTasks('grunt-continue');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-connect');
Expand All @@ -210,6 +217,8 @@ module.exports = function (grunt) {
grunt.registerTask('cover', ['karma:cover', 'remapIstanbul', 'site-meta']);
grunt.registerTask('site', ['build', 'cover', 'copy:site']);
grunt.registerTask('build', ['default', 'copy:npm']);
grunt.registerTask('tddTasks', ['ts', 'continue:on', 'karma']);
grunt.registerTask('tdd', ['tddTasks', 'watch']);

grunt.loadNpmTasks('grunt-bump');
grunt.loadNpmTasks('grunt-conventional-changelog');
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"license": "MIT",
"readmeFilename": "README.md",
"scripts": {
"tdd": "./node_modules/.bin/grunt tdd",
"start": "./node_modules/.bin/grunt serve",
"test": "./node_modules/.bin/grunt karma",
"postinstall": "./node_modules/.bin/typings install"
Expand Down Expand Up @@ -42,6 +43,7 @@
"grunt": "0.4.5",
"grunt-bump": "0.7.0",
"grunt-cli": "0.1.13",
"grunt-continue": "^0.1.0",
"grunt-contrib-clean": "0.7.0",
"grunt-contrib-connect": "0.11.2",
"grunt-contrib-copy": "0.8.2",
Expand Down

0 comments on commit 1b6ba0c

Please sign in to comment.