karma-jasmine

Ionic Jasmine : env.stopOnSpecFailure is not a function after compiled successfully

回眸只為那壹抹淺笑 提交于 2020-01-01 08:05:12
问题 Using Ionic with jasmine-karma, while run test, getting success compile but in jasmine dashboard getting empty screen with error in console. Following tutorial : https://leifwells.github.io/2017/08/27/testing-in-ionic-configure-existing-projects-for-testing/ "ts-loader": "^4.1.0", "jasmine-core": "^2.99.1" Error Messages : TypeError: env.stopOnSpecFailure is not a function at adapter.js:26 Error: Module build failed: TypeError: Cannot read property 'afterCompile' of undefined 回答1: The failure

testing ui-router stateprovider 'resolve:' values

◇◆丶佛笑我妖孽 提交于 2020-01-01 07:18:51
问题 I'm using jasmine+karma to run the following code... and get the following error: Expected { then : Function, catch : Function, finally : Function } to equal 123. Can someone help me understand why I don't get a resolved value for my promise. thanks 'use strict'; angular .module('example', ['ui.router']) .config(function($stateProvider) { $stateProvider .state('stateOne', { url: '/stateOne', resolve: {cb: function($q) { var deferred = $q.defer(); deferred.resolve(123); return deferred.promise

karma.conf.js automatic file ordering?

不羁岁月 提交于 2020-01-01 05:03:34
问题 I have a large angularjs project ordered by features. I'd like to setup unit testing but I'm having trouble getting the karma.conf.js file ordering setup. I tried specifying a simple glob pattern like **/*.js but many of my modules failed to load due to the ordering that they're included in Karma when ran. As I understand, it's alphabetical, first match. I was able to resolve this by manually figuring out the ordering by doing something like this: // list of files / patterns to load in the

karma.conf.js automatic file ordering?

ε祈祈猫儿з 提交于 2020-01-01 05:03:08
问题 I have a large angularjs project ordered by features. I'd like to setup unit testing but I'm having trouble getting the karma.conf.js file ordering setup. I tried specifying a simple glob pattern like **/*.js but many of my modules failed to load due to the ordering that they're included in Karma when ran. As I understand, it's alphabetical, first match. I was able to resolve this by manually figuring out the ordering by doing something like this: // list of files / patterns to load in the

Angular Karma Jasmine Error: Illegal state: Could not load the summary for directive

北慕城南 提交于 2019-12-31 10:56:52
问题 I'm developing a github repository (with angular 7 and angular-cli), and I have some tests with Karma and Jasmine working in the master branch. Now I'm trying to add lazy loading feature, the thing is, that the tests that before passed, now they do not. It's funny because only the tests from the lazy loading module are failing... Here is the code and the error: import {async, TestBed} from '@angular/core/testing'; import {APP_BASE_HREF} from '@angular/common'; import {AppModule} from '../..

Test for rejected promise with Jasmine

空扰寡人 提交于 2019-12-31 05:11:10
问题 In my Angular2 app which uses AngularFire2, I have an AuthService which tries to authenticate anonymously with Firebase. I am trying to write a test that expects AngularFireAuth 's signInAnonymously to return a rejected promise; for authState to be null and an error to be thrown. I an new to Jasmine and testing in general but I think I may need to be using asynchronous tests but I'm getting quite stuck. Here is a simplified AuthService : import { Injectable } from '@angular/core'; import {

Storing global variable in a separate file for Protractor Tests

淺唱寂寞╮ 提交于 2019-12-31 04:02:26
问题 I am trying to create a separate inventory file for Protractor Test where I can store all the reusable variable to be used by different test scrips. The sample Variable list is called Vars.js and the specs should import the variables from this file and consume those. However, this fails as shown below. Can this approach actually be used for storing reusable variables? Can I actually create a separate inventory file for protractor tests outside of conf.js? Vars.js has the following content :

How do I unit test $scope.broadcast, $scope.$on using Jasmine

偶尔善良 提交于 2019-12-31 03:56:06
问题 I'm newbie to AngularJs/NodeJs world, so forgive if this is a basic question to some. So in a nutshell I've two controllers, the first controller $broadcast an 'Id' and the second controller fetches that Id with $on and then passes that Id to an intermediate service , which makes an $http ajax call and returns a single Book object. How do I unit test $scope.broadcast, $scope.$on using Jasmine firstCtrl .controller('firstCtrl', function($scope, ...){ $scope.selectGridRow = function() { if(

Angular Material 2 - Trigger change event in md-checkbox in a Unit Test

纵饮孤独 提交于 2019-12-31 03:47:45
问题 I am having problems triggering a 'change' event for a md-checkbox in an Angular Unit Test, using the test framework setup provided by the Angular CLI. I have a simple component: ts: import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { checkedValue = 'false'; result = false; checkValueChange(event) { console.log('CheckBox clicked: ' + event.checked); this.result =

Explain karma unit test times

血红的双手。 提交于 2019-12-31 02:36:28
问题 I've been searching the web for this for two days and I found nothing. Maybe I'm looking in the wrong way — I don't know... So here it is: what are the times on my console when running a Karma+Jasmine+phantomJs unit test? ... Executed 1 of 1 SUCCESS (0.878 secs / 0.112 secs) First, I though that the second time is the total unit test time (for example, when running multiple tasks), however, sometimes the first time gets to be 'bigger', sometimes not... Anyone? 回答1: total time / net time net