Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

karma testing setup

  • Loading branch information...
commit a1364cb375a3833ee57a511a610767d211f99334 1 parent 17b1800
@treasonx treasonx authored
View
1  .gitignore
@@ -1,2 +1,3 @@
.DS_Store
node_modules/
+coverage/
View
24 Gruntfile.js
@@ -12,6 +12,26 @@ module.exports = function(grunt) {
src: ['src/node.js', 'src/priorityqueue.js', 'src/instance.js', 'src/easystar.js'],
dest: '',
}
+ },
+ karma: {
+ options: {
+ configFile: 'karma.conf.js'
+ },
+ dev: {
+
+ },
+ coverage: {
+ preprocessors: {
+ 'src/*.js': 'coverage'
+ },
+
+ browsers: ['PhantomJS'],
+ coverageReporter: {
+ type : 'html',
+ dir : 'coverage/'
+ },
+ reporters: ['coverage', 'progress']
+ }
}
});
@@ -25,5 +45,7 @@ module.exports = function(grunt) {
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
+ grunt.loadNpmTasks('grunt-karma');
+
-};
+};
View
13 README.md
@@ -106,6 +106,19 @@ In order to run the demo you will need node.js, and npm installed.
Open your browser to 127.0.0.1:3000 to see the example.
+## Testing
+
+This project is setup to use the [karma](http://karma-runner.github.io/0.10/index.html) test runner.
+
+### Development Testing
+
+run `grunt karma:dev` to start the karma test runner in dev mode. Once the karma server is up and running open [http://localhost:9876](http://localhost:9876) in your web browser. The tests will run automatically. View the results in your terminal window where you started the karma server. Editing any of the source or spec files will cause the tests to run again.
+
+### Coverage Testing
+
+run `grunt karma:coverage` to run the karma server in test coverage mode. Once the test run is complete open `coverage/Phantom**/index.html` in your web browser to view the test coverage report.
+
+once the karma server is running in test coverage mode you can visit [http://localhost:9876](http://localhost:9876) with any web browser to get a test coverage report for the connected browser.
## Roadmap
* Better test coverage
View
78 karma.conf.js
@@ -0,0 +1,78 @@
+// Karma configuration
+// Generated on Sun Nov 17 2013 05:27:43 GMT-0500 (EST)
+
+module.exports = function(config) {
+ config.set({
+
+ // base path, that will be used to resolve files and exclude
+ basePath: '',
+
+ plugins: [
+ 'karma-jasmine',
+ 'karma-coverage',
+ 'karma-phantomjs-launcher'
+ ],
+
+
+ // frameworks to use
+ frameworks: ['jasmine'],
+
+
+ // list of files / patterns to load in the browser
+ files: [
+ 'src/node.js',
+ 'src/priorityqueue.js',
+ 'src/instance.js',
+ 'src/easystar.js',
+ 'test/spec/*.js'
+ ],
+
+
+ // list of files to exclude
+ exclude: [
+
+ ],
+
+
+ // test results reporter to use
+ // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
+ reporters: ['progress'],
+
+
+ // web server port
+ port: 9876,
+
+
+ // enable / disable colors in the output (reporters and logs)
+ colors: true,
+
+
+ // level of logging
+ // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
+ logLevel: config.LOG_INFO,
+
+
+ // enable / disable watching file and executing tests whenever any file changes
+ autoWatch: true,
+
+
+ // Start these browsers, currently available:
+ // - Chrome
+ // - ChromeCanary
+ // - Firefox
+ // - Opera (has to be installed with `npm install karma-opera-launcher`)
+ // - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
+ // - PhantomJS
+ // - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
+ //browsers: ['PhantomJS'],
+
+
+ // If browser does not capture in given timeout [ms], kill it
+ captureTimeout: 60000,
+
+
+ // Continuous Integration mode
+ // if true, it capture browsers, run tests and exit
+ singleRun: false
+ });
+};
View
15 package.json
@@ -4,6 +4,19 @@
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-uglify": "~0.2.0",
- "grunt-contrib-concat": "~0.3.0"
+ "grunt-contrib-concat": "~0.3.0",
+ "karma-script-launcher": "~0.1.0",
+ "karma-firefox-launcher": "~0.1.0",
+ "karma-chrome-launcher": "~0.1.0",
+ "karma-html2js-preprocessor": "~0.1.0",
+ "karma-jasmine": "~0.1.3",
+ "karma-requirejs": "~0.1.0",
+ "karma-coffee-preprocessor": "~0.1.0",
+ "karma-phantomjs-launcher": "~0.1.0",
+ "karma": "~0.10.4",
+ "grunt-karma": "~0.6.2",
+ "karma-coverage": "~0.1.2"
+ },
+ "dependencies": {
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.