karma-runner

accessing $scope from unit test file when using the vm “ControllerAs” syntax from AngularJS HotTowel

拈花ヽ惹草 提交于 2020-01-20 17:09:50
问题 See here for example: http://www.johnpapa.net/angularjss-controller-as-and-the-vm-variable/ As the title suggests, I'm following along on this tutorial [http://tech.pro/tutorial/1473/getting-started-with-angularjs-unit-testing] to setup unit testing and all is fine EXCEPT for the fact I can't seem to access the vm variable as my $scope . dashboard.js var controllerId = 'dashboard'; angular.module('app') .controller(controllerId, ['common', 'datacontext', dashboard]); function dashboard(common

How to configure karma and systemjs to run tests for angular ES6 transpiled by traceur into amd format ES5 modules

て烟熏妆下的殇ゞ 提交于 2020-01-15 07:27:08
问题 Ok, I have been pounding my head against the desk for far too long, it is time to ask for help. Maybe I am way off base, or I just cannot see the trees in the forest. Please help. I am trying to build an application using gulp, Angular 1.3+, ES6, traceur, SystemJS, es_module_loader and http-server. So far the app is looking good, it compiles and runs and hosts just fine from the compiled folder location, but I cannot get Karma to run a single test within my compiled project. Here is my

Find a good way to get a coverage report with karma?

我们两清 提交于 2020-01-14 06:29:12
问题 I'm using karma-coverage + browserify + angular. The result i get from coverage is that 100% of the files under test are covered which is not true. Any idea how to make this work? This is my file karma.conf.js : // Karma configuration module.exports = function (config) { config.set({ // base path that will be used to resolve all patterns (eg. files, exclude) basePath: './', // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ['browserify',

LCOV.INFO has absolute path for SF

最后都变了- 提交于 2020-01-14 06:17:28
问题 I need to have relative path as value of SF: parameter in the lcov.info file generated by karma coverage. This is to enable SonarQube to gather the info to display the coverage. Currently, the SF parameter is having complete absolute path , e.g. c:\abc\xyz....\src\bar\foo.js I need to have SF: src\bar\foo.js Is there a way to achieve this? 回答1: Unfortunately it is still impossible out of the box. To fix the issue you can either: use istanbul merged with this request, process the output file

Uncaught ReferenceError: define is not defined

一曲冷凌霜 提交于 2020-01-14 04:10:29
问题 Thanks for any help you can offer. I have a Grails project that I'm trying to install Karma into. However, when I run ./gradlew build I get the following error: [x-10-105-56-234]SENG5199-twtr (BRANCH1) $ ./gradlew check :bowerInit UP-TO-DATE :nodeSetup UP-TO-DATE :bowerDependencies UP-TO-DATE :bowerConfig :bowerComponents UP-TO-DATE :bowerInstall UP-TO-DATE :compileJava UP-TO-DATE :compileGroovy UP-TO-DATE :processResources UP-TO-DATE :classes UP-TO-DATE :karmaInit UP-TO-DATE

Uncaught ReferenceError: define is not defined

烈酒焚心 提交于 2020-01-14 04:10:16
问题 Thanks for any help you can offer. I have a Grails project that I'm trying to install Karma into. However, when I run ./gradlew build I get the following error: [x-10-105-56-234]SENG5199-twtr (BRANCH1) $ ./gradlew check :bowerInit UP-TO-DATE :nodeSetup UP-TO-DATE :bowerDependencies UP-TO-DATE :bowerConfig :bowerComponents UP-TO-DATE :bowerInstall UP-TO-DATE :compileJava UP-TO-DATE :compileGroovy UP-TO-DATE :processResources UP-TO-DATE :classes UP-TO-DATE :karmaInit UP-TO-DATE

Module not found error in AngularJS unit test

随声附和 提交于 2020-01-13 13:52:44
问题 I'm trying a very simple test with Karma/Jasmine, to unit test my AngularJS app. This seems to work beforeEach( module('myApp') ); it('should blah', function () { expect(true).toBe(true); }); while this doesnt beforeEach( function () { module('myApp') } ); it('should blah', function () { expect(true).toBe(true); }); I want to be able to do other stuff beforeEach test suite, but it's not giving me any meaningful errors to be able to debug it, the only one I see is TypeError: 'undefined' is not

Module not found error in AngularJS unit test

匆匆过客 提交于 2020-01-13 13:52:25
问题 I'm trying a very simple test with Karma/Jasmine, to unit test my AngularJS app. This seems to work beforeEach( module('myApp') ); it('should blah', function () { expect(true).toBe(true); }); while this doesnt beforeEach( function () { module('myApp') } ); it('should blah', function () { expect(true).toBe(true); }); I want to be able to do other stuff beforeEach test suite, but it's not giving me any meaningful errors to be able to debug it, the only one I see is TypeError: 'undefined' is not

AngularJS: how to test directive which gives focus to element?

半世苍凉 提交于 2020-01-13 13:52:12
问题 Note: the suggested link is an answer to a question about a service, and doesn't give a clear explanation on how to solve this issue I'm trying to setup a karma test for my simple (and working) AngularJS autofocus directive: app.directive('autofocus', function ($timeout) { return { replace: false, link: function (scope, element, attr) { scope.$watch(attr.autofocus, function (value) { if (value) { $timeout(function () { element[0].focus(); console.log('focus called'); }); } } ); } }; }); This

grunt karma testing on vagrant when host changes sources grunt/karma doesn't detect it

谁说胖子不能爱 提交于 2020-01-13 10:15:29
问题 This took me ages to find out but can't seem to find a solution for this one. Using vagrant I run a Fedora 20 guest that runs grunt/karma. The sources I edit on my host but when I save grunt isn't detecting the change so no tests are being done. Figured it was a configuration problem so tried many combinations of things here without success. Finally I opened a second ssh to the guest vagrang ssh and changed the file in the other ssh terminal echo " " >> app/js/app.js and see that now grunt