karma-runner

TypeError: 'undefined' is not a function (evaluating 'mockBackend.expectPost(

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 12:55:01
问题 I am trying to unit test an angularjs controller with Karma, and jasmine. Here is my test suite: describe('Controllers', function(){ var $scope, ctrl; beforeEach(module('curriculumModule')); describe('CreateCurriculumCtrl', function(){ var mockBackend, location; beforeEach(inject(function($rootScope, $controller, _$httpBackend_, $location){ mockBackend = _$httpBackend_; location = $location; $scope = $rootScope.$new(); ctrl = $controller('CreateCurriculumCtrl', { $scope: $scope }); })); it(

Angular2 test fail when mocking a service

旧城冷巷雨未停 提交于 2019-12-23 12:39:07
问题 Trying to test a component with a service dependency that call rest API, made a mocked version of the service, with a class that extends the real service. Now if I override the provider with the mocked one, weird error comes out of karma reporter, first 404 for 2 not existing files (that really should not exist) and then "{originalErr: {}}". I mean at least tell me what I've done wrong :) My test suit: describe('App: HeaderComponent', () => { it('should get categories on initialization',

Testacular: encountered a declaration exception

北慕城南 提交于 2019-12-23 12:25:05
问题 I have defined a empty module in angular.js: angular.module('todoList', [], function () { }) then I want test it, in my conf.js , I load these javascript: files = [ JASMINE, JASMINE_ADAPTER, // lib '../js/lib/angular.min.js', '../js/lib/jquery-1.9.1.min.js', // our app '../js/project.js', // test file "test/*.js" ]; Then I want test it in test file: describe('My own function', function(){ beforeEach(module('todoList')); }); but this step tell me FAILED My own function encountered a

Error when running tests in VueJS: Unknown custom element: <router-link>

扶醉桌前 提交于 2019-12-23 10:25:24
问题 When I run my Karma/Jasmine tests I get a Error Log in the console after mounting my header component which include <router-link> components. It all run's perfectly fine but just can't seem fix the error that displays. The error is: ERROR LOG: '[Vue warn]: Unknown custom element: <router-link> - did you register the component correctly? For recursive components, make sure to provide the "name" option. (found in <Header>)' I have done the old: Vue.use(VueRouter) and am running "vue-router": "

Angular2 RC1 Karma Error - unable to find @angular/core/testing

你说的曾经没有我的故事 提交于 2019-12-23 09:57:36
问题 I am trying to setup Angular2 (RC1 version) project with Karma. I was able to do this setup for ng2 beta.17, but for RC1 I am getting the following error: Error: Error: XHR error (404 Not Found) loading http://localhost:9876/@angular/core/testing at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:9876/base/node_modules/zone.js/dist/zone.js?11128be53f306ea156f04e90b0fb7f23fc2104a5:748:30) at ZoneDelegate.invokeTask (http://localhost:9876/base/node_modules/ zone.js/dist/zone.js

phantomjs cannot start up

ε祈祈猫儿з 提交于 2019-12-23 09:18:23
问题 I used AngularJS in my project and karma to test. Then I configured karma like this: config.set({ basePath: '../', frameworks: ['jasmine'], files: [ // bower:js 'bower_components/jquery/dist/jquery.js', 'bower_components/angular/angular.js', 'bower_components/bootstrap/dist/js/bootstrap.js', 'bower_components/angular-animate/angular-animate.js', 'bower_components/angular-cookies/angular-cookies.js', 'bower_components/angular-route/angular-route.js', 'bower_components/angular-sanitize/angular

Karma: Is it possible to load JavaScript files statically before the requirejs framework?

情到浓时终转凉″ 提交于 2019-12-23 03:20:06
问题 I'm wondering if it's possible to configure Karma (0.10.9) to load certain JavaScript files before its requirejs framework? The reason I'm asking is that Knockout registers as a module with RequireJS if the latter has been included before Knockout, and this breaks another module (which doesn't support RequireJS). Basically, our karma.conf.js looks as below: module.exports = function (config) { config.set({ basePath: "Scripts", frameworks: ['mocha', 'requirejs'], files: [ "knockout-2.2.1.debug

unit testing angular service, beforeEach inject doesn't execute

两盒软妹~` 提交于 2019-12-23 03:00:57
问题 I'm trying to write unit tests for an angular service with jasmine/karma. I have a similar service test, which works just fine. But this one has some additional dependencies, is in a different module and just doesn't find the service with the inject. The service looks something like this. bService is in the same module, but commonFactory and commonService are in another module, say commonModule . (function () { 'use strict'; angular .module('myService') .service('aService', aService);

Testing function within same file is called

我只是一个虾纸丫 提交于 2019-12-23 02:55:07
问题 I have 2 functions where one calls the other and the other returns something, but I cannot get the test to work. Using expect(x).toHaveBeenCalledWith(someParams); expects a spy to be used, but I am unaware of how to spy on a function within the same file... Error: : Expected a spy, but got Function. Usage: expect().toHaveBeenCalledWith(...arguments) Example.ts doSomething(word: string) { if (word === 'hello') { return this.somethingElse(1); } return; } somethingElse(num: number) { var x = {

Concurrently node exits with status 1. This halts Teamcity leading it to believe that the tests failed

≯℡__Kan透↙ 提交于 2019-12-23 02:31:51
问题 I am trying to run two scripts at once with concurrently . The basic command looks something like this: concurrently -k --success first "node ./tools/mock-webapi/mock-webapi.js" "npm run test-single-run" Which in turn calls (local): "test-single-run": "karma start --single-run --browsers ChromeHeadless" Or on remote (teamcity host): "test-teamcity": "karma start --reporters teamcity --single-run --browsers ChromeHeadless", The tests run just fine (local & remote). However, I keep getting exit