jasmine

$httpBackend is undefined although angular-mock is included

爷,独闯天下 提交于 2019-12-07 15:26:31
This is my test. I get error that $httpBackend is undefined. describe("Objects Service", function () { var $httpBackend, $rootScope, scope, datacontext, config; beforeEach(function () { module('agApp'); }); beforeEach(inject(function ($rootScope, _$httpBackend_, _datacontext_, _config_) { scope = $rootScope.$new(); datacontext = _datacontext_; $httpBackend = _$httpBackend_; config = _config_; })); it("should call right API adress to get all objects", function () { $httpBackend.whenGET('/api/objects').respond(200); datacontext.objects.getObjects(function (data) { $httpBackend.flush(); }); });

Jasmine unit testing observable subscribe does not trigger

喜夏-厌秋 提交于 2019-12-07 15:06:50
问题 I'm using Angular 5 with Jasmine and Karma. I'm trying to test whether a certain function works but my subscribe doesn't trigger during unit testing. this causes my unit test to fail as I'm using the done function of jasmine. I want to make this unit test succeed. I've set the timeout interval to 20 seconds to see if it just took a while (which it shouldn't). I've tried to use async and fakeasync as well, but it doesn't trigger. Is it possible for me to make the subscription to trigger? this

Using Resharper test runner with Jasmine 2.0

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 14:48:02
问题 I'm trying to use the Resharper (v8.2) test runner in VS2013 with Jasmine 2 but I'm having an issue calling a 'global' beforeEach The spec file has a 'script reference' to a SpecHelper.js that has a call to beforeEach. The SpecHelper code is running but at the time that the SpecHelper is loaded Jasmine has not been loaded so beforeEach is not available. The code looks like this: ///<reference path="../../../../jasmine/tests/BaseReferences.js"/> then in the SpecHelper beforeEach(function() { /

Protractor - Page Object is not updating when the DOM elements are changed

一曲冷凌霜 提交于 2019-12-07 14:42:17
问题 I am testing a SPA built with angular.js and im using Page Objects pattern to write my tests. In the app we have a number of lists that will be updated. For example there is a list of attachments that will update when ever attachments are added/removed. To add an attachment we have a modal window and when we upload a file and click ok. The file uploads and the lists update. I have written 2 page objects, one for the upload modal window and the other one for the preview of the attachment list.

Angular unit testing: how to test controller properties without scope

拜拜、爱过 提交于 2019-12-07 13:41:42
问题 I'm trying to write some tests for a controller, but ALL the documentation/tutorials/etc on this demonstrate with functions and variables on $scope. What if you want to test something NOT on $scope? Ex: app.controller('fakeCtrl', function($scope) { var foo = 'bar'; function fooBar() { console.log('foo bar'); } }); Is there any way to unit test foo or fooBar() ? Here's what DOESN'T work: describe("fake controller", function(){ beforeEach(module('app')); var $controller; beforeEach(inject

Jasmine Tests give error “Uncaught ReferenceError: require is not defined”

落花浮王杯 提交于 2019-12-07 11:38:47
问题 I am trying to run Jasmine tests with Karma on my React site. My tests were working before, and I'm not sure what has changed, but now I get the error: Uncaught ReferenceError: require is not defined for Chrome and PhantomJS and Firefox give me similar errors. Please let me know if more info would be helpful. I have found a lot of similar questions on the web, but nothing that fixes the problem. You can see the test file below and the full project is on my github repo. Thanks in advance! My

RequireJS not loading modules properly using karma and typescript

无人久伴 提交于 2019-12-07 11:32:00
问题 I am trying to set up unit testing for a SPA using karma/jasmine First of all, the following test runs just fine in karma: /// <reference path="../../definitions/jasmine/jasmine.d.ts" /> /// <reference path="../../src/app/domain/core/Collections.ts"/> define(["app/domain/core/Collections"], (collections) => { describe('LinkedList', () => { it('should be able to store strings for lookup', () => { var list = new collections.Collections.LinkedList<string>(); list.add("item1"); expect(list.first(

Not able to run my test cases on protractor 2.5.1 and jasmine 1.3.1?

别等时光非礼了梦想. 提交于 2019-12-07 10:51:41
问题 my conf.js: exports.config = { seleniumAddress: 'http://localhost:4444/wd/hub', capabilities: { 'browserName': 'firefox' }, onPrepare: function() { browser.driver.manage().window().maximize(); protractor.basePath = __dirname; }, suites : { qa: ['./specs/log_in.js','./specs/create_project_external_roles.js','./specs/create_position_us_roles.js', beta: ['./specs/log_in_beta.js','./specs/create_position.js', './specs/candidate_status.js'], }, jasmineNodeOpts: { defaultTimeoutInterval: 3000000,

How do I access methods in React for unit testing

一个人想着一个人 提交于 2019-12-07 09:38:17
问题 I'm having an incredibly difficult time unit testing anything with React. The docs on TestUtils are sparse and there's no examples. Google seems to only be giving me a couple results. I'm using Jasmine, but that's not really the part that's giving me grief. Here's the simplest thing I've tried testing: var BigButton = React.createClass({ render: function () { return ( <button className="big-submit" data-color={this.props.color} onClick={this.props.action}>{this.props.text}</button> ); }, foo:

Chutzpah running Jasmine in TFS 2012 can't find referenced file under test

核能气质少年 提交于 2019-12-07 09:30:18
问题 I am using Chutzpah to run our Jasmine tests. I have added the Chutzpah dlls to the solution and updated the build to run *.js tests. The project structure is as follows: MyApp.Web Scripts App Home DateControl.js MyApp.Web.Tests Scripts Jasmine lib Chutzpah (dlls) Spec App Home DateControlSpecs.js The Jasmine test file uses a reference tag to reference the file to be tested /// <reference path="../../../../../../App.web/scripts/app/home/datecontrol.js" /> The Jasmine tests are run however I