jasmine

Angular2 testing service mocks

Deadly 提交于 2019-12-16 18:04:21
问题 I have a simple Angular2 component that consists of the following import { Component, OnInit, Input } from '@angular/core'; import {FooterLinksService} from './footer-links.service'; import { environment } from '../../environments/environment'; @Component({ selector: 'app-footer-links', templateUrl: './footer-links.component.html', styleUrls: ['./footer-links.component.css'], providers: [FooterLinksService] }) export class FooterLinksComponent implements OnInit { constructor(private

Executing .exe file using node runs only once in protractor

你说的曾经没有我的故事 提交于 2019-12-14 04:20:10
问题 I write some tests using jasmine and protractor i want in the @beforeeach to execute .exe file using require('child_process') and then @aftereach i will restart the browser. The problem is that the .exe file is executed only once with the first spec. here is the code in the beforeEach() beforeEach((done) => { console.log("before each is called"); var exec = require('child_process').execFile; browser.get('URL'); console.log("fun() start"); var child = exec('Test.exe', function(err, data) { if

Making all plugin specific rules strict

你说的曾经没有我的故事 提交于 2019-12-14 04:10:55
问题 In eslint.json configuration, ESLint allows to configure rule strictness using the following logic: 0 - "off" 1 - "warning" 2 - "error" Example: { "rules": { "jasmine/valid-expect": 2, "eqeqeq": [2, "smart"] } } Question: Is it possible to make all plugin-specific rules strict (code 2)? In this case, we want all rules coming from jasmine (eslint-plugin-jasmine plugin) produce an error if there is a violation. I've tried to specify "jasmine/*": 2 and "jasmine": 2 , but both failed with a

calling click() function on html element in jasmine-phantomjs test [duplicate]

二次信任 提交于 2019-12-14 02:46:05
问题 This question already has answers here : PhantomJS; click an element (11 answers) Closed 4 years ago . I run my tests with Karma and PhantomJS: INFO [karma]: Karma v0.12.32 server started at http://localhost:9876/ INFO [launcher]: Starting browser PhantomJS INFO [PhantomJS 1.9.8 (Windows 7)]: Connected on socket kVOvdbbgtIeUQuV8AAAA wit In the that test I want to click on the paragraph (p) to get my event-feedback: // given var element = appendToBody("<p id='hello-p'>Hello Hello World!</p>");

How to expose javascript objects for unit testing without polluting the global namespace

久未见 提交于 2019-12-14 00:32:07
问题 I have a javascript autocomplete plugin that uses the following classes (written in coffeescript): Query, Suggestion, SuggestionCollection, and Autocomplete. Each of these classes has an associated spec written in Jasmine. The plugin is defined within a module, e.g.: (function(){ // plugin... }).call(this); This prevents the classes from polluting the global namespace, but also hides them from any tests (specs with jasmine, or unit-tests with something like q-unit). What is the best way to

Protractor & Jasmine Configuration on Jenkins

五迷三道 提交于 2019-12-13 21:32:49
问题 I am trying to configure Protractor on Jenkins for CTI.... I have already setup Protractor along with Jasmine and trying to get it integrated with Jenkins. I have gone through several links & blogs on internet but none seem to be helpful in providing detailed information on how to get the Protractor configured with Jenkins. Any help or pointing towards the right blog or video will be really appreciated. Thanks 回答1: @Vishal Please find the below snippet you can add as grunt task. 'use strict';

Getting the angular app to run when using protractor

不想你离开。 提交于 2019-12-13 21:28:26
问题 I must be missing something here ... I'm trying to use protractor to run e2e tests for my angular application. The configuration file is something along the lines of: allScriptsTimeout: 11000, specs: [ 'src/**/*.e2e.js' ], capabilities: { browserName: 'firefox' }, baseUrl: 'http://localhost:8000/app/', framework: 'jasmine', jasmineNodeOpts: { showColors: true, isVerbose : true, includeStackTrace : true, defaultTimeoutInterval: 30000 } The test looks something like this: describe('example test

Cannot read property “loadListing” of Undefined -Karma Jasmine

拟墨画扇 提交于 2019-12-13 21:11:46
问题 This is my test case for checking whether the function is defined or not in the controller Function: $scope.loadData = ()=> { LoadService.loadListing().then(function (responseData) { alert("Success"); } Test Case: it('should have loadMeetings function', function () { expect(angular.isFunction(scope.loadData )).toBe(true); }); The Error : TypeError: Cannot read property 'loadListing' of undefined at Scope.MyCtrl.$scope.loadData 来源: https://stackoverflow.com/questions/27740395/cannot-read

Unit testing jQuery getJSON function errors with the fail method, using Jasmine and Karma

老子叫甜甜 提交于 2019-12-13 20:21:41
问题 I've written a unit test for a function that calls the jQuery getJSON method. The only thing that I'm testing is that it is called with the expected URL. My unit test uses a Jasmine Spy to mock the API call. However, when I run my unit tests I get this error: 1) should make a request to the expected URL when running on localhost test module getDataFromApi function TypeError: Cannot read property 'fail' of undefined In my unit test I've created a Jasmine Spy, which returns the done and fail

Angular injecting $service results in Unknown provider: $serviceProvider

时光总嘲笑我的痴心妄想 提交于 2019-12-13 18:03:38
问题 Why when I run this in the karma runner: describe('Service tests', function () { var DataServiceMock var httpBackend; beforeEach(angular.mock.module('app')); beforeEach(angular.mock.inject(function( $httpBackend, $service, DataService, $injector){ results in this error Error: [$injector:unpr] Unknown provider: $serviceProvider <- $service http://errors.angularjs.org/1.2.1/$injector/unpr?p0=%24serviceProvider%20%3C-%20%24service at /home/site/angular/angular.js:78:12 Edit 2_ _ __ _ __ _ __ _ _