karma-runner

Angular.js promise not resolving when unit testing service with karma

我的梦境 提交于 2019-12-19 19:54:09
问题 I am trying to unit test an Angular.js service, and need to set an expect on a promise returned from a Mock service (using Jasmine). I am using the karma unit testing framework. The relevant code snippet is below: // I can't figure out how to do the equivalent of a $scope.$digest here. var loginStatusPromise = FacebookService.getFacebookToken(); loginStatusPromise.then(function(token) { expect(false).toBeTruthy(); // If this test passes, there is something going wrong! expect(token).not

Babel / Karma / Chai gives TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions

寵の児 提交于 2019-12-19 16:37:27
问题 I having trouble figuring out why this test is not passing. var expect = require('chai').expect; describe('HelloComponent', function() { it('passes a quite simple test', function() { expect(1 + 4).to.equal(5); }); }); produces this error: DEBUG [web-server]: serving: /Users/ivan/dev/react-starter/node_modules/karma/static/context.html DEBUG [web-server]: serving (cached): /Users/ivan/dev/react-starter/node_modules/mocha/mocha.js DEBUG [web-server]: serving (cached): /Users/ivan/dev/react

UI Router Extras breaks my unit tests with unexpected results error?

↘锁芯ラ 提交于 2019-12-19 06:51:21
问题 QUESTION: - Why are my tests failing when ui-router-extras (not normal ui-router) is install? - How can I use ui-router-extras and still have my tests pass? If you want to install this quickly use yeoman + angular-fullstack-generator + bower install ui-router-extras I found a similar issue with normal ui-router. Luckially, ui-router normal works just fine with my testing. After installing ui-router-extras I get an ERROR If I uninstall ui-router.extras it this test passes just fine: UPDATED

UI Router Extras breaks my unit tests with unexpected results error?

帅比萌擦擦* 提交于 2019-12-19 06:51:18
问题 QUESTION: - Why are my tests failing when ui-router-extras (not normal ui-router) is install? - How can I use ui-router-extras and still have my tests pass? If you want to install this quickly use yeoman + angular-fullstack-generator + bower install ui-router-extras I found a similar issue with normal ui-router. Luckially, ui-router normal works just fine with my testing. After installing ui-router-extras I get an ERROR If I uninstall ui-router.extras it this test passes just fine: UPDATED

Jasmine 2.0 SpecRunner vs Karma

耗尽温柔 提交于 2019-12-19 05:11:49
问题 I just started using Jasmine and I was able to use the SpecRunner from the Html just fine. However when I configured Karma I encountered a discrepancy: describe('Calculator', function(){ var obj; beforeEach(function(){ //initialize object obj = new Object(); this.addMatchers({ toBeFive: function () { return { compare: function (actual, expected) { return { pass: actual === 5, message: actual + ' is not exactly 5' } } }; }, This piece of code does not work from the SpecRunner.html: this

Why is Karma refusing to serve my JSON fixture (which I'd like to use in my jasmine / angularjs tests)

主宰稳场 提交于 2019-12-19 03:38:23
问题 As indicated in this stackoverflow answer, it looks like Karma will serve JSON fixtures. However, I've spent too many hours trying to get it to work in my environment. Reason: I'm doing angular testing and need to load mock HTTP results into the test, as Jasmine doesn't support any global setup/teardown with mock servers and stuff. In my karma config file, I'm defining a fixture as so: files: [ // angular 'angular/angular.min.js', 'angular/angular-route.js', 'angular/mock/angular-mocks.js', /

Karma error when running angular2 tests via jenkins on linux

风流意气都作罢 提交于 2019-12-19 02:32:47
问题 I am seeing the following error when running my angular2 unit tests using karma with jenkins. My tests run fine when I run them on my local machine (windows), however when running the test via jenkins on linux I get the following error. Missing error handler on `socket`. TypeError: (msg || "").replace is not a function at /home/hudson/.hudson/jobs/workspace/pjt/node_modules/karma/lib/reporter.js:45:23 My tests are never started any ideas what could be causing this. I took a look at the karma

Karma jasmine tests: Highlight diff in terminal

♀尐吖头ヾ 提交于 2019-12-19 01:40:14
问题 I'm using Karma with Jasmine for my tests. In some tests, I have large objects that the test relies on. When I do something like expect(obj).toEqual(expectedObj); and obj != expectedObj , I get an error message in my terminal. But this error is really long , because it includes both of the objects, and it's very hard to see, in what parts the two objects are different. So, is there any highlighter for the terminal, that can be used along with karma? This way, it would be much more easy to

Open Karma debug.html page on startup

和自甴很熟 提交于 2019-12-18 20:48:01
问题 The short version: How do I start up Karma and have it open the debug.html file automatically in the same browser as the Karma start page? The long version: I'm not a huge fan of using the console reporters for Karma, so I have been using karma-jasmine-html-reporter-livereload which outputs to Karma's localhost:9876/debug.html file. The problem is, every time I start a debugging session, I have to click the 'debug' button in the web page that karma opens. I would like to find a way to have

Angular Jasmine UI router inject resolve value into test

♀尐吖头ヾ 提交于 2019-12-18 20:29:40
问题 In my Angular app, UI router resolves a promise into the controller. When trying to test this controller, Karma is complaining about an unknown provider. How do I inject a fake object into the test to represent this resolve object. My app's code looks something like: angular.module('myapp') .config(function($stateProvider, $urlRouterProvider) { $stateProvider .state('tab.name', { ... resolve: { allTemplates: function(Templates) { return Templates.all().then(function(templates) { return