Mock ngrx / store in Angular2 tests

Could you probably help me mocking the Store? I've seen this and this questions by a have a bit different error. I'm using store in one of my services, where I use dispatch, select and get store methods. I've mocked the Store following @noelmace sugg

Angular2 - HTTP call unit test

I am a beginner of angular2. My service.ts will be, import { Injectable } from '@angular/core'; import { Http, Response } from '@angular/http'; import {Headers, RequestOptions, URLSearchParams} from '@angular/http'; import {Observable} from 'rxjs/Obs

I'm having problems using log4js-protractor-appender

My log4js.js file code 'use strict'; var log4js = require('log4js'); var log4jsGen = { getLogger: function getLogger() { log4js.loadAppender('file'); log4js.addAppender(log4js.appenders.file('./ApplicationLogs.log'), 'logs'); var logger = log4js.getL

How to check headers in any angular request?

I've been trying to test the process when any request was sended and I want check if the headers are ok. What have I done wrong? check this codepen: App.js angular .module('exampleApp') .config(configFn); conf

Testing a controller with a specific syntax

Whenever, I am testing a controller and have something like this in it. $scope.isSomething = function (Item) { return ItemCollection.someItem(Item.attachedItem); }; giving error on karma console: TypeError: undefined is not an object (evaluating 'Ite

Running Jasmin tests via Webpack (Terminal) to test Angular2

Currently I'm trying to get Jasmine to run along with Webpack, to execute tests written in typescript to test Angular2 Apps in the Terminal. I researched yesterday which packages are available for testing, and while angular2 has their own approach *1

toBe (true) vs toBeTruthy () vs toBeTrue ()

What is the difference between expect(something).toBe(true), expect(something).toBeTruthy() and expect(something).toBeTrue()? Note that toBeTrue() is a custom matcher introduced in jasmine-matchers among other useful and handy matchers like toHaveMet

How to run a single test file with Karma / Jasmine?

I'm using Karma and Jasmine for testing my Angular JS code. I managed to run all the tests in my project using Karma, but if I try to run just a single file I'm getting the following error: ReferenceError: describe is not defined. Is it possible to r

Waiting fails for internal HTML verification

For some reason my assert in protractor fails, what i'm trying to do is get the innerHTML (text) from an element: var stuff = $('css').html(); expect(stuff).toBe("Inner HTML Text here"); I verified that the $().html() yields the text i desire on

Verbal output in jest js

is any option for verbore output for testing by jest? I can see which modules are mocked. I tried jasmine.VERBOSE = true; but not working. Thanks for answer.To get verbose mode in Jest, you can run Jest with the --verbose tag. In your packages.json,

Why karma does not run any tests?

I've created a JHipster project and created a javascript spec, however when I run karma start I'm getting this output: ~/projetos/consami/src/test/javascript$ karma start INFO [karma]: Karma v0.12.31 server started at http://localhost:9876/ INFO [lau

Jasmine-gem / jasmine: ci: How to console.log?

I'm using the jasmine-gem as part of a rails project. I know I can run the tests in a browser with rake jasmine, but I need to run them headless via rake jasmine:ci. When I'm running them in headless/ci mode, console.logs do not get outputted. How ca

Angular tests with Jasmine can not compare the html node

I am building directive tests in Angular using Jasmine. I have a small example test which looks like this: it("should compare html node", inject( function ($compile, $rootScope) { var elm = angular.element('<input>'); elm = $compile(elm)($

Jasmine js: Add a source method for running the test

I have as simple "hello world" project and I want to test the famous hélloWorld function. The project is structured like this: ├── package.json ├── spec │ ├── helloWorldSpec.js │ └── support │ └── jasmine.json └── src └── helloWorld.js And the f

Angular / jasmine / promise / mockery test

I'm a little screwed up with angular / jasmine / promise / mocking testing. I have a piece of code: factory.login = function(user, pwd) { AuthenticationResource.login( {}, {"username" : user, "password" : pwd}, factory.onLoginSuccess,

Grunt and test database

I'm currently running my test suite on AngularJS using Grunt, Karma, Jasmine and Protractor. The database library I'm using is, which is a library on top of CouchDB. I start using the following code in my Gruntfile: hoodie: { start: {

Write angular unit tests after writing the application?

I've inherited a medium sized angular app. It looks pretty well organized and well written but there's no documentation or unit tests implemented. I'm going to make an effort to write unit tests posthumously and eventually work in e2e tests and docum

Failed to test Angular service with simulated $ http in Jasmine

I am trying to test an Angular service which wraps my API calls. For testing I'm using Jasmine and Karma. My test looks like this: describe('$http basic', function () { var ConcernService, $httpBackend, $scope; beforeEach(module('concernsApp')); befo

Angular jqLite: .find () will not work - does not select tags

I have this unit spec in jasmine: define(['common/components/directives/directives', 'angular'], function (directives, ng) { describe('The directives module', function () { beforeEach(function () { ng.mock.module('directives'); }); describe('The tabs

Revealing Module Pattern - Unit Tests with Jasmine

After a brief romance with the revealing module pattern I've come to realise a set-back when it comes to unit-testing modules. I cannot however decide if it is my approach to testing a module or whether there is some form of work-around. Consider the

Prevent Jasmine's spy from listening to incorrect messages

How can I tell the Jasmine spy to only listen the messages I tell it to expect and ignore any others? For example: Example Group describe 'View', -> describe 'render', -> beforeEach -> @view = new View @view.el = jasmine.createSpyObj 'el', ['appe

How can I focus on a specification of jasmine.js?

I have a bunch of failing specs from a rather large architectural change. I'd like to work on fixing them one by one by tagging each one with 'focus'. Does jasmine.js have a feature like this? I swore I read at one point that it does but I don't see