jasmine

How to test a directive's controller using angularJS-karma-jasmine?

随声附和 提交于 2019-12-05 01:40:30
问题 Goal: Write a passing test for the waCarousel directive scope variable: self.awesomeThings . Expect this test pass when self.awsomeThings.length.toBe(3) to is true? Question: How can I properly write this test? rather how do I inject a directives controller? Directive: angular.module('carouselApp') .directive('waCarousel', function() { return { templateUrl: '../../../views/carousel/wa.carousel.html', controller: function($scope) { var self = this; self.awesomeThings = [1, 2, 3]; return $scope

Protractor error Angular could not be found on the page

帅比萌擦擦* 提交于 2019-12-05 01:31:08
I'm trying to set up End-2-End testing for my Angular (1.4) site using protractor (2.1.0). Jasmine is installed and unit tests are working fine. When I run protractor the index#/login page loads in a browser window but no code runs and protractor reports this error Failed: Angular could not be found on the page http://localhost/SpectrumGMWeb/index.html#/login : retries looking for angular exceeded My protractor config looks like this exports.config = { allScriptsTimeout: 11000, seleniumAddress: 'http://127.0.0.1:4444/wd/hub', specs: [ '*.js' ], rootElement:'html', capabilities: { 'browserName'

Angular2 - http call Code coverage

时光毁灭记忆、已成空白 提交于 2019-12-05 01:04:30
My components.ts is, getHomePageData() : void{ this.homeservice.getHomePageData() .subscribe( data => { //console.log("response status ################### "+data.status); //console.log("getUserData response ************ \n"+JSON.stringify(data)); this.defaultFacilityId = data.response.defaultFacilityId; this.defaultFacilityName = data.response.defaultFacilityName; this.enterpriseId = data.response.enterpriseId; this.enterpriseName = data.response.enterpriseName; this.facilityList = data.response.facilityList; this.userName = data.response.userName; this.showDefaultPopoup(); }, error => {

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

本小妞迷上赌 提交于 2019-12-05 01:03:40
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 run just a single test file and if yes then how? P.S. I'm using Intellij IDEA. Pieter Willaert Although it's not ideal, you can replace describe (and it ) with fdescribe (and fit ) so only those tests will be executed On the other hand, xdescribe / xit excludes the tests from your suite If you use Gulp, you can combine gulp-karma & yargs to pass in

jasmine-jquery loadFixtures with Jasmine 2.0 won't work

吃可爱长大的小学妹 提交于 2019-12-05 00:51:47
问题 I've spent about a day debugging this, and I'm at a loss. It looks like something isn't working in jasmine-jquery 2.0.2. I'm updating from Jasmine 1.3.1 and jasmine-jquery 1.5 to the newest versions. I am getting various failures depending on how I attempt to load fixtures. I get " Fixture could not be loaded: ./ExposureWorksheetFixture.html (status: parsererror, message: Invalid XML" after I tweaked jasmine-jquery to supply parameters to the ajax.fail() method. Another effect I have, when I

How to import 'describe', 'expect' and 'it' into a typescript tests for IDE to not to highlight them

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 00:39:31
问题 Wrote some tests and everything successfully runs, but my IDE (webstorm) highlights describe , expect and it and says "cannot find name". I want to keep everythig clean and get rid of these, but have no idea how. We use protractor and jasmine. Some more of the script: import {HomePO} from './pageobjects/home' import {browser } from 'protractor' describe('Smoke test', function() { it('should initialize', function() { let width = 320; let height = 568; browser.driver.manage().window().setSize

App folder is not loading in Ext.appliation when i try to test using jasmine

风流意气都作罢 提交于 2019-12-05 00:32:26
I am trying to implement jasmine in my application(Ext js 5)for unit testing. For that i have created app-test file. Ext.require('Ext.app.Application');Ext.Loader.setConfig({enabled:true}); Ext.onReady(function() { var Application = Ext.create('Ext.app.Application', { name: 'epmct', appFolder:'app', launch: function() { Ext.create('epmct.view.vpp.dashboard.VppDashboardMainPage'); } }); }); When i run the application throught specrunner.html(File to start unit testing ) I am getting error Uncaught Error: [Ext.Loader] Some requested files failed to load. and I tried to set path using Ext.Loader

How do I write FileReader test in Jasmine?

泪湿孤枕 提交于 2019-12-05 00:14:33
I'm trying to make this test work, but I couldn't get my head around how to write a test with FileReader. This is my code function Uploader(file) { this.file = file; } Uploader.prototype = (function() { function upload_file(file, file_contents) { var file_data = new FormData() file_data.append('filename', file.name) file_data.append('mimetype', file.type) file_data.append('data', file_contents) file_data.append('size', file.size) $.ajax({ url: "/upload/file", type: "POST", data: file_contents, contentType: file.type, success: function(){ // $("#thumbnail").attr("src", "/upload/thumbnail"); },

how to mock ngrx selector in a component

烈酒焚心 提交于 2019-12-05 00:09:58
In a component, we use a ngrx selector to retrieve different parts of the state. public isListLoading$ = this.store.select(fromStore.getLoading); public users$ = this.store.select(fromStore.getUsers); the fromStore.method is created using ngrx createSelector method. For example: export const getState = createFeatureSelector<UsersState>('users'); export const getLoading = createSelector( getState, (state: UsersState) => state.loading ); I use these observables in the template: <div class="loader" *ngIf="isLoading$ | async"></div> <ul class="userList"> <li class="userItem" *ngFor="let user of

How do I fake-time a jQuery animation using Sinon in a Jasmine unit test?

好久不见. 提交于 2019-12-05 00:00:40
I have a 1 second jQuery .animate action that launches 5 seconds after page load. I set up a Sinon timer in my Jasmine unit testing code and test after a tick of 7 seconds to see if the post-animation properties are as they should be. It doesn't work right, so I've placed an instance of the animation itself on my Jasmine HTML test page to better see what's going on. In Firefox and Chrome, the page loads, the animation function is called, the unit test immediately fails, and then (also immediately) the animation visibly occurs. In IE, Opera and Safari, the page loads, the animation function is