Skip to content

Commit

Permalink
feat(app generator,test): replace mocha/chai based testing framework …
Browse files Browse the repository at this point in the history
…with a combo of karma, jasmine, phantomjs and browserify
  • Loading branch information
cueedee committed Aug 26, 2016
1 parent b01860a commit 925d1ca
Show file tree
Hide file tree
Showing 7 changed files with 358 additions and 39 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,20 +175,31 @@ command | description
`grunt doc` | will build just the code documentation;
`grunt lint` | will just lint your code;
`grunt test` | will run your test suite;
`grunt test:dev` | will run your test suite and will keep monitoring it for changes, triggering re-runs;
`grunt --help` | will show you all of the above and the kitchen sink;


## Unit tests

BAT comes with support for unit testing using [Mocha](http://mochajs.org/) and [Chai](http://chaijs.com/). The demo webapp has a basic (and admittedly, pretty unconnected) example of this.
BAT comes with support for unit testing using [Karma](http://karma-runner.github.io/1.0/), [Jasmine](http://jasmine.github.io/2.4/introduction.html) and [PhantomJS](http://phantomjs.org/).

You may already have guessed how to independently run your test suite; it's:
Unit testing is an integrated build step in both `default` and `debug` build runs, but can also be run independently as:

```shell
grunt test
```

The default and `debug` grunt tasks also include the `test` task. You may or may not want to add it to your `dev` task too, depending on your workflow.
And as watched, continuous test runs as:

```shell
grunt test:dev
```

The latter invocation, while it is kept running, also offers the opportunity to launch a test suite run in any browser, simply by directing it to this url:

[`http://localhost:9876/debug.html`](http://localhost:9876/debug.html)

*Do not forget to open your dev tools and browser console there!*


## ChangeLog
Expand Down
26 changes: 23 additions & 3 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,13 @@ var AppGenerator = generators.Base.extend(
// Testing:

, 'test'
, 'test/unit'
, 'test/unit/asset'
, 'test/unit/spec'
, 'test/unit/spec/collections'
, 'test/unit/spec/mixins'
, 'test/unit/spec/models'
, 'test/unit/spec/views'

// Third-party, external libraries:

Expand Down Expand Up @@ -420,6 +427,11 @@ var AppGenerator = generators.Base.extend(
, [ 'settings/testing.json' ]
, [ 'settings/local.json' ]

// Testing:

, [ 'test/unit/init.coffee' ]
, 'test/unit/spec/trivial.spec.coffee'

]
;

Expand Down Expand Up @@ -486,7 +498,6 @@ var AppGenerator = generators.Base.extend(
[
'browserify'
, 'browserify-shim'
, 'chai'
, 'coffeeify'
, 'coffee-script'
, 'grunt'
Expand All @@ -500,12 +511,18 @@ var AppGenerator = generators.Base.extend(
, 'grunt-contrib-uglify'
, 'grunt-contrib-watch'
, 'grunt-contrib-yuidoc'
, 'grunt-mocha-test'
, 'grunt-karma'
, 'grunt-template'
, 'handlebars'
, 'hbsfy'
, 'mocha'
, 'jasmine-core'
, 'karma'
, 'karma-browserify'
, 'karma-jasmine'
, 'karma-phantomjs-launcher'
, 'phantomjs-prebuilt'
, 'standard-version'
, 'watchify'
]
;

Expand Down Expand Up @@ -673,6 +690,9 @@ var AppGenerator = generators.Base.extend(
+ chalk.bold( ' * ' + chalk.yellow( 'grunt test ' ))
+ '- will run your test suite;\n'

+ chalk.bold( ' * ' + chalk.yellow( 'grunt test:dev ' ))
+ '- will run your test suite and will keep monitoring it for changes, triggering re-runs;\n'

+ '\n'
+ chalk.bold( ' * ' + chalk.yellow( 'grunt --help ' ))
+ '- will show you all of the above and the kitchen sink;\n'
Expand Down
Loading

0 comments on commit 925d1ca

Please sign in to comment.