jasmine

Jasmine: How to see the reports in the browser?

前提是你 提交于 2020-01-03 09:47:32
问题 THE SITUATION: I am currently running AngularJs unit tests in the console. I open the folder in the console and i run karma start and check the result of the tests in the console. I would like to see the results in the browser but I cannot see them so far. All i can see is this: THE QUESTION: How can i see the reports of the tests in the browser? The proper plugin should be karma-jasmine-html-reporter right? THE CONFIGURATION: karma.conf.js: frameworks: ['jasmine'], files: [ 'bower_components

Angular 2 Integration Testing (Unit Test Style)

孤街浪徒 提交于 2020-01-03 09:05:43
问题 Is it possible to test an angular app with its testing framework (primarily designed for unit testing) against a real backend? Let's say E2E Testing with Protractor is not an option for me, but still i want to do some integration tests within my Unit Test Environment with Karma. I really have trouble finding examples or even a statement if it's possible or not using Jasmine and the testing libs of angular 2. I know, that this isn't supposed to be best (or even just a good) practice, but that

AngularJS unit testing with ReSharper

南笙酒味 提交于 2020-01-03 08:32:22
问题 I'm trying to get Jasmine unit tests for an AngularJS controller running with the ReSharper test runner so I can run my client and server-side tests in one place within VS 2012. I'm running into an issue where the ReSharper test runner is failing with a message of "Inconclusive: Test wasn't run". The same test runs fine using the test runner that comes with the AngularJS Seed project. Here's my simple test for troubleshooting: /// <reference path="~/Scripts/angular/angular.js"/> ///

How can I use jasmine.js to test for console output?

泪湿孤枕 提交于 2020-01-03 08:22:47
问题 I'm working through the text: Professional JavaScript for Web Developers by Nicholas Zakas and I'm testing the examples with Jasmine.js. I can currently test the output of a function by specifying a return a value, but I'm running into trouble when there are multiple pieces of data that I want to return. The textbook uses the alert() method, but this is cumbersome and I don't know how to test for alerts. I was wondering if there was a way to test for console.log() output. For instance:

Conflict between zone.js and Jasmine's clock

*爱你&永不变心* 提交于 2020-01-03 07:18:28
问题 I am working with a Jasmine testing suite that includes both "vanilla" Jasmine tests along with Jasmine tests for some Angular 2 components. Because of Angular 2's inclusion, zone.js gets loaded. This creates a conflict with Jasmine's clock. For example, the following test fails with the error, Error: Jasmine Clock was unable to install over custom global timer functions. Is the clock already installed? describe('an async test with zone.js present', function() { beforeEach(function() {

Which scenarios we want to use constructor injection and spyon() injection? and which one is best?

你离开我真会死。 提交于 2020-01-03 05:34:11
问题 My Componenet MaintainCOCComponent constructor have an parameter for MaintainCOCService which is have API call method service. export class MaintainCOCComponent { constructor( private maintaincocservice: MaintainCOCService) { } } Constructor injection: Here i have configured testBed and injected with a mock MockMaintainCOCService service via provider TestBed.configureTestingModule({ imports: [FormsModule, RouterTestingModule.withRoutes([])], declarations: [MaintainCOCComponent], providers: [

how to remove Unexpected request: GET data.json?

非 Y 不嫁゛ 提交于 2020-01-03 03:48:25
问题 I am trying to use $httpBackend to test my $http request ..i AM getting this error Unexpected request: GET data.json No more request expected here is my testing code beforeEach(inject(function($rootScope,$controller,appfactory,_$httpBackend_) { $scope = $rootScope.$new(); $httpBackend=_$httpBackend_; ctrl = $controller('cntrl', {$scope: $scope}); fac=appfactory; modeSpy= spyOn(fac, 'mode').and.returnValue('a'); })); it('test true value',function(){ expect(true).toBeTruthy() }) it('check

Angular Service Member Variable Not Accessible in Unit Tests

微笑、不失礼 提交于 2020-01-03 03:47:06
问题 I am trying to test my Angular service, and part of what the service does is load a JSON file that is used as configuration for the service. I have confirmed in the tests (through console.log ) that the way I am mocking the HTTP.get call to get the configuration is working and is returning the mocked config object: // mocking the loading of the configuration in the beforeEach authenticationService.loadInternalAuthModuleConfiguration(); const req = httpTestingController.expectOne('./internal

Protractor compare string numbers

萝らか妹 提交于 2020-01-03 03:09:09
问题 Today I've faced interesting problem of create test for pretty simple behavior: 'Most recent' sorting. All what test need to know: Every item have ID Previous ID is less then next in this case of sorting Approach : writing ID in to attribute of item, getting that id from first item with getAttribute() and either way for second. Problem : getAttribute() promise resulting with string value and Jasmine is not able to compare (from the box) string numbers. I would like to find elegant way to

Using loops in Jasmine (with injected service)

余生颓废 提交于 2020-01-02 21:57:14
问题 I'm using jasmine 2.3. Following this: http://tosbourn.com/using-loops-in-jasmine/ I placed a FOR loop directly in the ' describe ' nested function describe('service Profile', function() { var ProfileService; beforeEach(function() { module('app.services.profile'); inject(function(_ProfileService_) { ProfileService = _ProfileService_; }); }); describe('method setProfile', function() { function setProfileTest(key) { it('should set the object profile', function() { expect(ProfileService.profile