Skip to content

Commit

Permalink
Update to Karma 0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtajina committed Apr 13, 2013
1 parent 0955673 commit ddef88f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 44 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
tpl/*.js
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,25 @@ For instance, if we found a bug in the controller, we would add a lightweight un
This was nice, but how about external templates ?
Inlining html templates as strings is kind of nasty (eg. you don’t get syntax highlighting and linting in IDE), so we want to put the templates into external html files.
How do you test that? You want to test these html files as well, otherwise it makes no sense.
Well, with [Testacular] this is pretty easy - [you can use preprocessors for that](https://github.com/vojtajina/ng-directive-testing/commit/use-preprocessor).
Well, with [Karma] this is pretty easy - you can use `html2js` preprocessors for that.

Now, whenever you change any of the html files, Testacular immediately generates the js file, that puts the html into `$templateCache`.
Now, whenever you change any of the html files, Karma immediately generates the js file, that puts the html into `$templateCache`.

------

Note, you need testacular v0.3.0+ to use this feature, so install canary to try it.
### Install Karma

npm install -g testacular@canary
````
npm install -g karma
````

### Start Karma

There's also a grunt task to watch the templates and generate the js file, that puts the template into `$templateCache`.

grunt watch:templates
````
karma start
````


[AngularJS]: http://angularjs.org
[angular homepage]: http://angularjs.org/#create-components
[Testacular]: https://github.com/vojtajina/testacular
[Karma]: https://karma-runner.github.com
34 changes: 0 additions & 34 deletions grunt.js

This file was deleted.

4 changes: 2 additions & 2 deletions testacular.conf.js → karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ files = [

// generate js files from html templates
preprocessors = {
'**/*.html': 'html2js'
'tpl/*.html': 'html2js'
};

// list of files to exclude
Expand All @@ -37,7 +37,7 @@ exclude = [];

// test results reporter to use
// possible values: dots || progress
reporter = 'progress';
reporters = ['progress'];


// web server port
Expand Down
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "ng-directive-testing",
"version": "0.0.0",
"description": "An example of testing AngularJS directives with Karma.",
"main": "\"\"",
"scripts": {
"test": "karma start --single-run --no-auto-watch"
},
"repository": {
"type": "git",
"url": "git://github.com/vojtajina/ng-directive-testing.git"
},
"author": "Vojta Jina <[email protected]>",
"license": "MIT",
"readmeFilename": "README.md",
"gitHead": "f5d7ad2369e0ae0eaf9f3df4117c8d38f0a80631",
"devDependencies": {
"karma": "~0.8"
}
}

0 comments on commit ddef88f

Please sign in to comment.