diff --git a/Gruntfile.js b/Gruntfile.js index 2aa2e74..c243d20 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -82,7 +82,7 @@ module.exports = function(grunt) { } }); - grunt.registerTask('test', 'Run the jasmine and nodeunit tests', ['eslint', 'webpack:global', 'nodeunit', 'karma:single', 'ts']); + grunt.registerTask('test', 'Run the jasmine and nodeunit tests', ['eslint', 'nodeunit', 'karma:single', 'ts']); grunt.registerTask('build', 'Run webpack and bundle the source', ['webpack']); grunt.registerTask('publish', 'Prepare the code for release', ['clean', 'test', 'build', 'usebanner', 'update_json']); }; diff --git a/karma.conf.js b/karma.conf.js index ba9264f..c628821 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -15,8 +15,7 @@ module.exports = function(config) { // list of files / patterns to load in the browser files: [ - 'dist/axios.js', - 'test/specs/**/*.spec.js' + 'webpack.tests.js' ], @@ -29,7 +28,12 @@ module.exports = function(config) { // preprocess matching files before serving them to the browser // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { - 'dist/axios.js': 'coverage' + 'webpack.tests.js': ['webpack', 'sourcemap', 'coverage'] + }, + + + webpack: { + devtool: 'inline-source-map' }, @@ -38,12 +42,14 @@ module.exports = function(config) { // available reporters: https://npmjs.org/browse/keyword/karma-reporter reporters: ['progress', 'coverage'], + coverageReporter: { type: 'lcov', dir: 'coverage/', subdir: '.' }, + // web server port port: 9876, diff --git a/package.json b/package.json index 5a684cb..6f7b399 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "karma-jasmine": "^0.3.5", "karma-jasmine-ajax": "^0.1.12", "karma-phantomjs-launcher": "^0.1.4", + "karma-webpack": "^1.5.0", "load-grunt-tasks": "^3.1.0", "webpack": "^1.7.2", "webpack-dev-server": "^1.7.0" diff --git a/test/specs/api.spec.js b/test/specs/api.spec.js index f751b95..fbc8e5e 100644 --- a/test/specs/api.spec.js +++ b/test/specs/api.spec.js @@ -1,3 +1,5 @@ +var axios = require('../../index'); + describe('api', function () { it('should have request method helpers', function () { expect(typeof axios.get).toEqual('function'); @@ -26,4 +28,4 @@ describe('api', function () { expect(typeof axios.all).toEqual('function'); expect(typeof axios.spread).toEqual('function'); }); -}); \ No newline at end of file +}); diff --git a/test/specs/interceptors.spec.js b/test/specs/interceptors.spec.js index 85b48c4..89e2c4d 100644 --- a/test/specs/interceptors.spec.js +++ b/test/specs/interceptors.spec.js @@ -1,3 +1,5 @@ +var axios = require('../../index'); + describe('interceptors', function () { beforeEach(function () { jasmine.Ajax.install(); diff --git a/test/specs/options.spec.js b/test/specs/options.spec.js index 01efa91..a910662 100644 --- a/test/specs/options.spec.js +++ b/test/specs/options.spec.js @@ -1,3 +1,5 @@ +var axios = require('../../index'); + describe('options', function () { beforeEach(function () { jasmine.Ajax.install(); diff --git a/test/specs/promise.spec.js b/test/specs/promise.spec.js index c34dbaf..f15d626 100644 --- a/test/specs/promise.spec.js +++ b/test/specs/promise.spec.js @@ -1,3 +1,5 @@ +var axios = require('../../index'); + describe('promise', function () { beforeEach(function () { jasmine.Ajax.install(); diff --git a/test/specs/transform.spec.js b/test/specs/transform.spec.js index acace2a..e04607d 100644 --- a/test/specs/transform.spec.js +++ b/test/specs/transform.spec.js @@ -1,3 +1,5 @@ +var axios = require('../../index'); + describe('transform', function () { beforeEach(function () { jasmine.Ajax.install(); diff --git a/test/specs/wrapper.spec.js b/test/specs/wrapper.spec.js index f1cde3a..b404189 100644 --- a/test/specs/wrapper.spec.js +++ b/test/specs/wrapper.spec.js @@ -1,3 +1,5 @@ +var axios = require('../../index'); + describe('wrapper', function () { beforeEach(function () { jasmine.Ajax.install(); diff --git a/test/specs/xsrf.spec.js b/test/specs/xsrf.spec.js index c50850d..518ae25 100644 --- a/test/specs/xsrf.spec.js +++ b/test/specs/xsrf.spec.js @@ -1,3 +1,5 @@ +var axios = require('../../index'); + describe('xsrf', function () { beforeEach(function () { jasmine.Ajax.install(); diff --git a/webpack.tests.js b/webpack.tests.js new file mode 100644 index 0000000..ed890d0 --- /dev/null +++ b/webpack.tests.js @@ -0,0 +1,2 @@ +var context = require.context('./test/specs', true, /\.js$/); +context.keys().forEach(context);