Issue I am trying to create a E2E test using angular-js and karma, but for some reason the test is not progressing and hangs on the navigateTo(). the code I am using is describe(‘Login’, function(){ beforeEach(function(){ browser().navigateTo(‘http://localhost/blah’); window.sleep(1); }); it(‘should
Continue readingTag: karma-runner
Karma: Testing on multiple browsers, each on different proxies
Issue I need each browser that I’ll be running my e2e tests on (chrome, safari, firefox) to each run the test suite through different proxies. Is there a way I can do this in the karma.conf.js file? At the moment
Continue readingAngular e2e test to check a list of elements
Issue My case is as follows – I have a simple page which lists available products: <ul class=”products ng-scope” id=”products”> <!– ngRepeat: tag in products –> <li ng-repeat=”product in products” class=”ng-scope”> <a ng-href=”/#/viewProduct/1″ class=”ng-binding” href=”/#/viewProduct/1″>Product A</a> </li><li ng-repeat=”product in products”
Continue readingAngularJS e2e test – $routeParams always empty
Issue I’m trying to write an end-to-end test of my AngularJS app where I check that when a certain parameter is in the URL, something happens. However, $routeParams is an empty object. This guy had the same problem. I’m trying
Continue readingselect(name).option(value) selects wrong option?
Issue I’ve a got a strange issue. When I try to select a date the select() function selects the wrong option. Ng-Model: days = [’01’, ’02’, ’03’, ’04’, …, ’31’]; Markup: <select ng-model=”day” id=”day” name=”day” ng-options=”day for day in days”>
Continue readingFull Jquery support in Karma E2E testing in AngularJs
Issue How do I access the full JQuery library within my Karma E2E tests? Solution Are you using a config file? Just include it like any other: files = [ JASMINE, JASMINE_ADAPTER, ‘angular.js’, ‘jquery.js’, // etc… ]; Answered By –
Continue readingAngularJS e2e tests hang when changing between two separate angular apps
Issue I have a frustrating problem: I want to write end to end tests for a complex angular app. The problem is that the login screen is a separate app. The initial idea was that it would branch out to
Continue readingJavascript.confirm() and Angularjs Karma e2e test
Issue I have an Angularjs application that uses simple javascript confirm before executing some actions. Controller: function TokenController($scope) { $scope.token = ‘sampleToken’; $scope.newToken = function() { if (confirm(“Are you sure you want to change the token?”) == true) { $scope.token
Continue readingAngularJS : e2e tests with Karma Scenario Test Runner using cached source?
Issue I am trying to set up some AngularJS e2e tests with Karma Scenario Test Runner. I did some modifications to the source files, but Karma doesn’t seem to use these latest versions when testing. In the source files, I
Continue readingmaxlength on field not working with Karma
Issue I have a field with a maxlength of 6, but somehow the following way of entering data results in 7 chars being allowed: <input type=”text” name=”myName” maxlength=”6″ ng-model=”myModel”> this is the test bit: input(‘myModel’).enter(‘1111117’); expect(input(‘myModel’).val()).toBe(111111); and this is the
Continue readingTravis build failing on "The SUID sandbox helper binary was found, but…"
Issue My Angular app tests are passing locally, however they are failing on travis with the following error: The SUID sandbox helper binary was found, but is not configured correctly. Rather than run without sandboxing I’m aborting now. You need
Continue readingAngular Karma Throws Uncaught Error: Missing jasmine.js
Issue I’ve created a new angular project and wanted to run tests with ng test. But I’m getting a lot of Pattern ** does not match any file errors. The launched chrome window remains blank and I’m getting an uncaught
Continue readingKarma tests randomly restart and "double" iframe in Edge
Issue I have a suite of Karma/Jasmine tests for my Angular 7 app. All my tests pass in Chrome and Firefox, but when I run them in Edge it will run for a little bit and then sometimes it will
Continue readingError while running test in angular : The pipe 'paginate' could not be found ("
Issue I am running an angular test & I am getting the following error. UserActivitiesComponent should create Failed: Template parse errors: The pipe ‘paginate’ could not be found (" <div class="row row-style" *ngFor="let [ERROR ->]item of result | paginate: {
Continue readingAngular mock fails to inject my module dependencies
Issue I want to test an Angular controller for my application fooApp, defined as follow: var fooApp = angular.module(‘fooApp’, [ ‘ngRoute’, ‘ngAnimate’, ‘hmTouchEvents’ ]); … The controller, MainCtrl is defined: “use strict”; fooApp.controller(‘MainCtrl’, function ($scope, $rootScope, fooService) { … }
Continue readingkarma/jasmine/angular toHaveBeenCalledWith is really called
Issue in my app for instance I’ve got $rootScope.$emit(‘loggedin’,data.user); $rootScope.$on(‘loggedin’, function(event,user) { console.log(‘called’); }); in my test spyOn($rootScope, ‘$emit’); var response = { “success”:1, “user”:{ “id”:1, “email”:”lama@test.test”, “fullname”:”Lama user”, “username”:”lamauser”, “groups”:[“Users”] }, “logged”:1 }; $httpBackend.when(‘POST’, ‘/api/v1/user’).respond(200,response); $scope.save(); $httpBackend.flush(); expect($scope.errors.length).toEqual(0); expect($rootScope.$emit).toHaveBeenCalledWith(‘loggedin’,response.user);
Continue readingkarma/angularjs how to test run block with service
Issue This post follow this I’ve posted an other thread with a easier example code to test ‘use strict’; var app = angular.module(‘myApp’, []); app.run(function ($rootScope, Menus) { var menus = [ { ‘permission’: null, ‘title’: ‘Home’, ‘link’: ‘home’ },
Continue readingkarma/angularjs how to test run block with an asynchronous service
Issue How can I test like: init.js lama.system module angular.module(‘lama.system’, []) .config([‘$httpProvider’, function($httpProvider) { // Crossdomain requests not allowed if you want do cors request see filter.php $httpProvider.defaults.headers.common[‘X-Requested-With’] = ‘XMLHttpRequest’; }]) .run([‘$rootScope’, ‘$state’, ‘$log’, ‘Global’,function ($rootScope, $state, $log, Global) {
Continue readingError: [$injector:unpr] Unknown provider: $$rAFProvider
Issue Using Karma to test Angular getting error: Error: [$injector:modulerr] Failed to instantiate module ngMock due to: Error: [$injector:unpr] Unknown provider: $$rAFProvider Angular mock, Angular versions error? I’ve heard solutions detailing changing of angular-mock version or angular version–which seems like
Continue readingbrowserify/karma/angular.js "TypeError: Cannot read property '$injector' of null" when second test uses "angular.mock.inject", "currentSpec" is null
Issue I have an Angular.js app and am experimenting with using it with Browserify. The app works, but I want to run tests too, I have two jasmine tests that I run with karma. I user browserify to give me
Continue readingAngularJS Testing and $http
Issue So Im trying to figure out how to write unit tests for my angular controller. I am using karma as my runner. I was able to write 1 successful test but every time I try to write another test
Continue readingCordova sqliteplugin karma test description
Issue Hello I want to implement some test cases for my ionic framework application which uses cordova sqliteplugin to get data from a sqlite database. I’m very new in writing test cases for angularjs. My goal is to test if
Continue readingAngular services not being defined in beforeEach in Karma
Issue I have an Angular Application using Jasmine and Karma for testing. This is my testing class: var data = require(‘./user.mock.js’); describe(‘Service: UserService’, function () { var ServerUrl; var httpBackend; var userService; beforeEach(angular.mock.module(‘myModule’)); beforeEach(angular.mock.inject(function (_userService_, $httpBackend, _ServerUrl_) { userService =
Continue readingMocking $window object inside Angular .config
Issue I am getting following error while trying to run karma tests spec in my app. Error: [$injector:modulerr] Failed to instantiate module adf.widget.tabularWidget due to: Error: Failed to execute ‘atob’ on ‘Window’: The string to be decoded is not correctly
Continue readingTesting $interval in Jasmine/ Karma
Issue I have a simple factory angular.module(‘myApp.dice’,[]).factory(‘Dice’, [‘$interval’, function($interval){ return { rollDice: function(){ return $interval(function(c){ count++; }, 100, 18, false, 0); } }; }]); In my test case I have describe(‘rolling dice’, function(){ var promise, promiseCalled = false, notify =
Continue readingWhy does this test for the angular-google-maps provider fail?
Issue I’m trying to test a module that uses angular-google-maps. It is failing because angular.mock.inject cannot find uiGmapGoogleMapApiProvider: Error: [$injector:unpr] Unknown provider: uiGmapGoogleMapApiProviderProvider <- uiGmapGoogleMapApiProvider I can’t figure out what is going wrong. Here is the reduced testcase: ‘use strict’;
Continue readingHow to test the config function of an Angular module?
Issue I’m defining some setup code in the config function of an Angular module that I want to unit test. It is unclear to me how I should do this. Below is a simplified testcase that shows how I’m getting
Continue readingkarma test returning validateAmount is not a function
Issue I’m trying to test scope function which will check due amount, but while running the test I’m getting validateAmount is not a function. app.js var ManagmentApp = angular.module(“ManagemntApp”, [‘ngRoute’, ‘angularModalService’, ‘ng-fusioncharts’]); ManagmentApp.config([‘$routeProvider’, function ($routeProvider){ $routeProvider.when(‘/’, { templateUrl: ‘templates/CandidateForm.html’, controller:
Continue readingTypeError: angular.element.cleanData is not a function
Issue I’m getting the following error in my karma unit test when trying to use inject() Example ✗ should wait for promise to resolve and have a result Error: timeout of 2000ms exceeded. Ensure the done() callback is being called
Continue readingGetting a `$digest already in progress` error when testing a `catch()` error handler
Issue This is my test: it(‘add.user() should POST to /users/, failure’, function() { mockBackend.expectPOST(“/users/”, {username:’u’, password: ‘p’, email: ‘e’, location: ‘loc’}).respond(400, {msg: “bad request”}); BaseService.add.user({username:’u’, password: ‘p’, email: ‘e’, location: ‘loc’}); mockBackend.flush(); }); afterEach(function() { mockBackend.verifyNoOutstandingExpectation(); mockBackend.verifyNoOutstandingRequest(); }); And when
Continue readingSetting up webpack karma and angular-mocks
Issue I have this problem setting up my webpack. I’m setting up webpack on an existing project and additionally I’m introducing ES6. I would like to do it in the ‘correct’ manner having tests passing after some big change.That’s why
Continue readingAngular 1.5 Karma unit test loads ng-mock twice
Issue I have a web app written with Typescript 2.4.2, compiled by latest Webpack version (2.7.0). I’m in the process of adding Karma tests using Jasmine as the assertion library. This is my karma config file: ‘use strict’; const webpack
Continue readingAngular 1.6.0: "Possibly unhandled rejection" error
Issue We have a pattern for resolving promises in our Angular app that has served us well up until Angular 1.6.0: resource.get().$promise .then(function (response) { // do something with the response }, function (error) { // pass the error the
Continue readingHow to write unit test to Restangular with Jasmine?
Issue I know how to write test to GET methods, but what with other methods? PUT, PATCH, DELETE? This is for example my service method to remove user: removeOne: function(user) { var deferred; console.log(user); deferred = $q.defer(); if (_.isUndefined(user.id) ||
Continue readingAngularjs e2e testing past/future comparisons
Issue I’m currently trying to figure out if there is a way to do a simple future/past comparison ex. 1) Check state of list by getting list length 2) Perform action which if success increments the list 3) Compare the
Continue readingIs it possible to mix Testacular (Karma) with angular-scenario?
Issue Testacular (now Karma) is awesome, so is angular-scenario. Using them together is proving a challenge however. There is an ANGULAR-SCENARIO-ADAPTER in Testacular, but that breaks simple tests. If you include angular-scenario.js yourself Testacular will run no tests at all.
Continue readingTesting a non-trivial AngularJS app with Karma
Issue I’ve been writing attempting to setup a testing suite for an application that I’ve been developing. The app is hosted locally, and on most accounts works fine. I’ve tried to setup karma via the instructions on AngularJS’s site, and
Continue readingAngular Karma e2e with Grunt
Issue I am trying to test In the grunt file karma: { e2e: { configFile: ‘karma-e2e.conf.js’, singleRun: true } }, Karma file is basically what Yeoman generated for me. Only change is I swithed Chrome for PhantomJS. karma-e2e.conf.js: // Karma
Continue readingTestacular does not run e2e test
Issue Once again I have problems running my angularJS e2e test with testacular. This time the output is Chrome 23.0: Executed 0 of 13 (skipped 13) SUCCESS (0.117 secs / 0 secs) info: Disconnecting all browsers no test are run,
Continue readingUnit Testing Services in AngularJS with Jasmine, Karma and ng-Mock
Issue I’m having trouble accessing my services and filters in unit tests (I haven’t tried directives yet). I’ve written unit tests before, but as I have moved to the configuration of our builds, I’m having trouble accessing our new services
Continue readingHybrid Angular App Testing with Karma Cannot Load HTML
Issue We have a hybrid Angular app that uses karma for unit testing. I’m trying to add our first suite of tests but I’m getting some errors that indicate karma cannot find the dashboard.component.html. View: import { Component, OnInit }
Continue readingTesting Angular component with unsubscribe Error during cleanup of component
Issue I’m testing a component which subscribe router params. Every test pass and everything works fine. But if I look in the console, I can see an error: Error during cleanup of component ApplicationViewComponent localConsole.(anonymous function) @ context.js:232 Do you
Continue reading"Ctrl + click to follow link" in VSCode terminal does not jump to source file but opens new browser tab
Issue I’m using Visual Studio Code (version 1.40.1) to work on my Angular 8 project and run Karma/Jasmine tests from its terminal through the command ng test. When a test failed, I was always able to jump to the related
Continue readingAngular 7 Test: NullInjectorError: No provider for ActivatedRoute
Issue Hi have some error with testing my App made with Angular 7. I do not have much experience in angular, so I would need your help+ Error: StaticInjectorError(DynamicTestModule)[BeerDetailsComponent -> ActivatedRoute]: StaticInjectorError(Platform: core)[BeerDetailsComponent -> ActivatedRoute]: NullInjectorError: No provider for ActivatedRoute!
Continue readingTesting Ionic Toast button click in Jasmine
Issue I am unable to query for one of the Toast buttons inside while testing. It simply returns null. The class is set, and that is what is being used to query. it(‘should make a call to retrieval method on
Continue readingAngular test cannot find the open dialog
Issue I have an angular component (HostComponent) that contains some buttons which should open a dialog. I am writing a test for this HostComponent using Angular’s TestBed. In the test, I select the button, click it and try to assert
Continue readingWhat should I use instead of fit and fdescribe in Jasmine 3?
Issue I get the error: ERROR: ‘DEPRECATION: fit and fdescribe will cause your suite to report an ‘incomplete’ status in Jasmine 3.0′ I did a RTFM for Jasmine 3.0 but it did not mention anything about deprecation: https://jasmine.github.io/api/3.0/global.html#fit Solution They
Continue readingERROR in ./src/polyfills.ts Module not found: Error: Can't resolve 'zone.js/dist/zone'
Issue I have an angular 8, that uses karma/jasmine to run some unit tests. I can run tests by executing the following command ng test but I’m getting the following error: ERROR in ./src/polyfills.ts Module not found: Error: Can’t resolve
Continue readingERROR in ./src/polyfills.ts Module not found: Error: Can't resolve 'zone.js/dist/zone'
Issue I have an angular 8, that uses karma/jasmine to run some unit tests. I can run tests by executing the following command ng test but I’m getting the following error: ERROR in ./src/polyfills.ts Module not found: Error: Can’t resolve
Continue readingJasmine: "Incomplete: No specs found" in Angular Typescript project
Issue For some reason I can’t understand, Karma says that Jasmine can’t find any of my test specs. I’m using Angular 9, Typescript and ng test to run the tests. I also ran jasmine init to create the jasmine.json config
Continue readingHow can I mock an Observable.throw in an Angular2 test?
Issue I want to test the error handling in my Angular2 component and therefore want to mock a service to return an Observable.throw(‘error’). How can that be done using Jasmine and Karma and Angular 2? Solution You should create an
Continue readingCan I run Karma Tests with a specified seed?
Issue I’m working in an Angular Project that is tested with Karma/Jasmine. Angular tests, by default, run in a randomized order, which may result a test failing if ran in a certain order. I’ve noticed that in my browser runner,
Continue readingHow to unit test a function returning a Promise with then block
Issue I have this code to initialize an authentication using OAuth2 and redirect the user to an authentication server before getting to my application import {Component} from ‘@angular/core’; import {JwksValidationHandler, OAuthService} from ‘angular-oauth2-oidc’; import {authConfig} from ‘./sso.config’; @Component({ selector: ‘app-root’,
Continue readingAngular jasmine toHaveBeenCalledWith with queryParams not working
Issue I have this test: it(‘should redurect to admin programs’, () => { … expect(navigateSpy).toHaveBeenCalledWith([‘/admin/programs’, {queryParams: {pub_status: ‘active’}}]); }); And its throwing this error: Error: Expected spy navigate to have been called with [ [ ‘/admin/programs’, Object({ queryParams: Object({ pub_status:
Continue readingKarma Disconnected reconnect failed before timeout Nightmare
Issue I have my angular application with more than 5000 test cases. It has been running ok before I upgraded to Angular 13 and Karma 6.3, Jasmin 3.6 After upgrade, I am getting this error while running "ng test". Disconnected
Continue readingHow can I execute ng test for all components of sub modul of Angular app
Issue I have my angular app, declared like this: app.module.ts export class AppModule {} for which I can run tests with ng test MyApp Within this app, I have multiple modules, declared like this: my-one.module.ts / my-other.module.ts export class MyOneModule
Continue readingAngular 1.5 Component template unit test with Karma Jasmine
Issue I am trying to unit test an Angular Components and templates with Karma Jasmine. I’m using ng-html2js Testing component controller is achieved but not template I’m referencing this Git Repository as part of this.The karma-conf file is same as
Continue readingHow to spyOn inner method and return a desired value?
Issue I have been trying to change the value that returns a method from a provider inside the method I am testing. I need to force bdbPlatforms.isBrowser() to return false I know is possible to call spyOn() the method and
Continue readingAngular Karma Testing – browser property as Chrome vs ChromeHeadless
Issue I’m working in an Angular 9 project, and we’re running tests with Karma. Can anyone explain to me the difference between setting the browser property (in karma.conf.js) as Chrome and ChromeHeadless? The only real I see is that is
Continue readingUnit test for service with Jasmine does not return data
Issue guys! I’m new in testing person and stuck with this issue. I’m trying to write the unit test for my service, which getting data from the server. Classical case: import {TestBed} from ‘@angular/core/testing’; import {ShiftsService} from “./shifts.service”; import {Shift}
Continue readingAngular component (with a directive) testing
Issue I have a component I want to test. The test fails with message AdminPanelComponent > should create TypeError: Cannot read property ‘role’ of undefined error properties: Object({ ngDebugContext: DebugContext_({ view: Object({ def: Object({ factory: Function, nodeFlags: 50577443, rootNodeFlags: 1,
Continue readingAngular 8 testing error Unexpected value 'DecoratorFactory' imported by the module 'DynamicTestModule'
Issue I am trying to make Jasmine & Karma framework into the current angular application running in ver 8.2. But i am coming across this weird error inside the Karma test running window: Failed: Unexpected value ‘DecoratorFactory’ imported by the
Continue readingKarma-Jasmine: Unexpected request: GET … No more request expected
Issue THE SITUATION: I am testing two different http calls in my AngularJs app. There is a strange behavior. If i test each one separately, with the other temporary commented out (in the controller and in the test) each one
Continue readinghow to fix 404 warnings for images during karma unit testing
Issue I’m unit testing one of my directives (angularjs) using grunt/karma/phantomjs/jasmine. My tests run fine describe(‘bar foo’, function () { beforeEach(inject(function ($rootScope, $compile) { elm = angular.element(‘<img bar-foo src=”img1.png”/>’); scope = $rootScope.$new(); $compile(elm)(); scope.$digest(); })); …. }); but I do
Continue readingTest component with a providers
Issue I have a service SoundPanelService which is used in service isolation scenario ( like https://angular.io/guide/hierarchical-dependency-injection#scenario-service-isolation ) @Injectable() export class SoundPanelService { recorded = new Subject<Sound>(); constructor() { } } and I have SoundPanelComponent Component({ selector: ‘app-sound-panel’, templateUrl: ‘./sound-panel.component.html’, styleUrls:
Continue readingKarma1.7 + AngularJS1.8.2 using $compile method causes unconfigurable property error
Issue Recently updated angularjs app from 1.5.11 to 1.8.2 This broke several of our unit tests. All seem to be throwing the error: TypeError: Attempting to configurable attribute of unconfigurable property. After some debugging, this happens whenever one of our
Continue readingHow to fix error "Please set env variable CHROME_BIN" when running Angular.js with grunt
Issue I am trying to do unit tests with AngularJS. I already have bower and grunt installed, so I should be able to do the tests. However, when I run “grunt test” from the terminal (Git Bash in my case),
Continue readingWhy do my unit tests pass with Chrome and fail with PhantomJS?
Issue I am using Angular2 final (2.0.2) with angular-cli. I am trying to set it up for running unit tests with PhantomJS. Running the specs with Chrome and karma-chrome-launcher works – all tests pass. Running the same with Phantomjs-prebuilt 2.1.13
Continue readingHow to configure Karma to include global scss files for an angular-cli project?
Issue I cannot configure angular-cli + scss + karma to test my components together. Running ng test the kamra unit tests are only including the components’ own scss styles. In order to apply my main styles.scss in tests, I’ve tried
Continue readingERROR in error TS2688: Cannot find type definition file for 'jest'
Issue I have an angular 6 application and I’m using karma + jasmine to run my tests. but when I run ng test I’m getting the following error: ERROR in error TS2688: Cannot find type definition file for ‘jest’. Any
Continue readingWhy does my karma-config.js triggers multiple launches of karma, with only the first working?
Issue A CircleCI CI/CD pipeline handling an Angular 7 application fails during the test step, with the CircleCI log suggesting the browser is not registered, although it runs once and it works! I’m building a CircleCI CI/CD pipeline for an
Continue reading"ng e2e" is failling probably in reason of proxy but "ng serve" and "ng test" are working
Issue I download https://github.com/blizzerand/pastebin-angular and I can successfully run "ng test" or "npm run test" (I understand both do exactly the same). C:\_pocs\ws_vsc\pastebin-angular-master>npm run test > test-angular@0.0.0 test C:\_pocs\ws_vsc\pastebin-angular-master > ng test 10% building modules 1/1 modules 0 active29 12
Continue reading"ng e2e" is failling probably in reason of proxy but "ng serve" and "ng test" are working
Issue I download https://github.com/blizzerand/pastebin-angular and I can successfully run "ng test" or "npm run test" (I understand both do exactly the same). C:\_pocs\ws_vsc\pastebin-angular-master>npm run test > test-angular@0.0.0 test C:\_pocs\ws_vsc\pastebin-angular-master > ng test 10% building modules 1/1 modules 0 active29 12
Continue readingsome of your test did a full page reload
Issue When i doing angular unit test,caught this error ALERT: ‘Add Success!’ Chrome 58.0.3029 (Windows 10 0.0.0) ERROR Some of your tests did a full page reload! Chrome 58.0.3029 (Windows 10 0.0.0): Executed 0 of 1 ERROR (0.503 secs /
Continue readingExpectation fails, when testing code in javascript fetch.then block
Issue I try to verify that window.open() is called within a then block. Here is a minimal example. import { fakeAsync, tick } from ‘@angular/core/testing’; function openWindow() { const linksource = `data:application/pdf;base64,somePDF`; fetch(linksource).then(() => { window.open(); }); } describe(‘Asynchronus Testing’,
Continue readingHow to write unit-test for http-post inside an observable in jasmine?
Issue I have web.service.ts, and I want to write a unit-test for this. But I am stuck in one method. updateClientConfiguration(id, data){ var res = this.http.post<any> (`${this.configUrl}/${this.helper.getNodeIP()}/clients/${id}`,data); //1 res.subscribe(result => { //2 if(data.type == “aws”) { console.log(“Updating AWS UI”); }
Continue readingNG Test cannot use Karma custom launchers
Issue I am trying to run Karma via the Angular CLI headlessly for CI, but I can’t get Karma to use my custom launcher. As per this page on the Angular website I am using a customLauncher property in my
Continue readingangular cli exclude files/directory for `ng test –code-coverage`
Issue I am running the following command to unit test and generate code code coverage report. ng test –code-coverage It is working fine and writing code coverage report in coverage folder. In this I got all files and directory coverage
Continue readingAngular CLI – Get coverage report to include all sources
Issue I am trying to figure out how to include all my .ts sources in the generated coverage report from the angular CLI. Currently I am only getting coverage for files that have an associated spec with tests against. I
Continue readingAngular Karma Jasmine Error: Illegal state: Could not load the summary for directive
Issue 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
Continue readingHow can I run tests with a headless browser?
Issue Using: ng test Angular CLI runs the tests by default in Chrome, which is great, but what if I need to run them in a console-only environment (headless browser)? Also it would be nice if I can specify if
Continue readingRunning a single test file
Issue Is there a way to run ng test for a single file instead of for the entire test suite? Ideally, I’d like to get the quickest possible feedback loop when I’m editing a file, but karma executes the whole
Continue readinglog4js-node-DEP0004 – Deprecation warning in Angular 12 karma unit tests
Issue I’m getting the following deprecation warning when running unit tests in a brand new Angular 12 application: (node:14940) [log4js-node-DEP0004] DeprecationWarning: Pattern %d{DATE} is deprecated due to the confusion it causes when used. Please use %d{DATETIME} instead. why log4js prompts
Continue readingkarma plugin dependencies not being found
Issue When I run karma start I get the following issues C:\devl\JS\myProject>karma start 06 09 2015 11:30:19.133:WARN [plugin]: Cannot find plugin “karma-chrome-launcher “. Did you forget to install it ? npm install karma-chrome-launcher –save-dev 06 09 2015 11:30:19.149:WARN [plugin]: Cannot
Continue readingMocking $httpBackend – how to handle "Unexpected request, No more request expected"?
Issue I have a Jasmine test that is coded like this: it (“should send correct message to server to get data, and correctly set up scope when receiving it”, function(){ $httpBackend.when(‘GET’, ‘https://localhost:44300/api/projectconfiguration/12’).respond(fakedDtoBase); $routeParams.projectId=fakeId; // user asks for editing project scope.$apply(function(){
Continue reading"Server start failed on port 9876: Error: EACCES: permission denied" on 'ng test' Angular Unit Tests
Issue Whilst running my Unit Tests in watch mode, Chrome suddenly quit and I now can no longer run ‘ng test’. This randomly occurred, and has not happened in over a year of working on these tests. The error I
Continue readingnpm check and update package if needed
Issue We need to integrate Karma test runner into TeamCity and for that I’d like to give sys-engineers small script (powershell or whatever) that would: pick up desired version number from some config file (I guess I can put it
Continue readingKarma – Chrome Headless – test FAILED – Uncaught null thrown
Issue While running unit tests, they fail "sometimes", always on different tests, without any meaningful error. … Chrome 89.0.4389.114 (Linux x86_64): Executed 1225 of 1453 SUCCESS (0 secs / 3 mins 29.829 secs) Chrome 89.0.4389.114 (Linux x86_64): Executed 1226 of
Continue readingHow to include lib to karma tests?
Issue I’m trying to use external libs in tests. I added all needed links in karma.conf.js and some libs were included without any problem. But for some libs karma sets "undefined" instead of "this" when compiling they, like this: And
Continue readingAngular Jasmine, unit test case fails when global variable assigned
Issue I have a basic unit-test case written for two methods. it(‘should populateChartDatasets call getColorCodes’, () => { component.chartConfig = mockChartConfig; spyOn(component, ‘getColorCodes’); component.populateChartDatasets(filteredTreatments, filteredYears); expect(component.getColorCodes).toHaveBeenCalled(); }); method populateChartDatasets firstly supposed to pick colorCode from method getColorCodes then push prepared
Continue reading