I am trying to test an angularjs app. I managed to get some basic test running on my laptop. These tests just check for a module and check some basic functions. This works fine on my laptop. However when I move the testing environment to a local server the tests stop working. For example regardless of what module name I pass in the test still passes. I haven't tried testing any functions yet. Just a module test.
app.js:
var app = angular.module('mcqsApp', []);
simpleTest.js:
describe('SimpleService test', function(){
beforeEach(function(){
module('blah');
});
it('SimpleService should have a module',function(){
});
});
karma.conf.js:
module.exports = function(config){
config.set({
// root path location that will be used to resolve all relative paths in files and exclude sections, should be the root of your project
basePath : '../',
// files to include, ordered by dependencies
files : [
// include relevant Angular files and libs
'http://ift.tt/1DTrZWe',
'http://ift.tt/1EbSm9o',
// include js files
'../../../public/js/app.js',
'../../../public/js/services/*/*.js',
// include unit test specs
'test/unit/services/*.js'
],
// files to exclude
exclude : [
],
// karma has its own autoWatch feature but Grunt watch can also do this
autoWatch : true,
// testing framework, be sure to install the karma plugin
frameworks: ['mocha', 'chai'],
// browsers to test against, be sure to install the correct karma browser launcher plugin
browsers : ['PhantomJS'],
// progress is the default reporter
reporters: ['mocha'],
// map of preprocessors that is used mostly for plugins
preprocessors: {
},
// list of karma plugins
plugins : [
'karma-junit-reporter',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-mocha',
'karma-chai',
'karma-sinon',
'karma-mocha-reporter',
'karma-phantomjs-launcher'
]
})}
It is my understanding that this should fail if the module names do not match. But this test will pass regardless of the module name. Any help would be greatly appreciated. If you guys need o see any more code such as my karma.conf.js file just ask and I will make an update.
Aucun commentaire:
Enregistrer un commentaire