jasmine

Jasmine in a separate test project

拈花ヽ惹草 提交于 2019-12-20 09:47:52
问题 Is it practical/possible to separate jasmine tests into a separate visual studio project? I am just getting started with angular, and am trying to write my tests before I start on the actual angular implementation. I will be writing my project in Visual Studio 2012 with the Chutzpah test runner , see this video. Currently, I am trying to figure out how to organize my folder structure. I know about angular-seed and yeoman, but those are ill suited to starting a .net project. I am assuming that

Test AngularJS factory function with Jasmine

萝らか妹 提交于 2019-12-20 09:07:15
问题 I am very new to this (angularjs, jasmine, testacular) and I have this code (I simplified it a bit, leaving only what matters): //my_module.js angular.module('my_module', ['my_data']) .config([...]); .controller('my_controller', ['$scope', 'my_data', function($scope, my_data) { $scope.my_function = function() { return my_data.my_factory.save().then(function () { console.log('saved'); }, function() { console.log('Error'); }); } } ) //my_data.js angular.module('my_data', []) .factory('my

Test AngularJS factory function with Jasmine

天涯浪子 提交于 2019-12-20 09:05:23
问题 I am very new to this (angularjs, jasmine, testacular) and I have this code (I simplified it a bit, leaving only what matters): //my_module.js angular.module('my_module', ['my_data']) .config([...]); .controller('my_controller', ['$scope', 'my_data', function($scope, my_data) { $scope.my_function = function() { return my_data.my_factory.save().then(function () { console.log('saved'); }, function() { console.log('Error'); }); } } ) //my_data.js angular.module('my_data', []) .factory('my

what is the real difference between ng test and ng e2e

江枫思渺然 提交于 2019-12-20 08:48:11
问题 I am afraid someone close my question but I couldn't find a satisfying question (maybe because I am very limited in Angular 2+ world and I understood something wrong). As far as I could understand after few Hello World done and few YouTube demo watched: ng test: you write your test using Jasmine language you test your test with many Browsers available using Karma you execute either unit or integrated testing all xxx.compnent.spec.ts run and a final report similar to JUnit is showed in browser

Frontend testing: what and how to test, and what tool to use?

倾然丶 夕夏残阳落幕 提交于 2019-12-20 07:59:15
问题 I have been writing tests for my Ruby code for a while, but as a frontend developer I am obviously interested in bring this into the code I write for my frontend code. There is quite a few different options which I have been playing around with: CasperJS Capybara & Rspec Jasmine Cucumber or just Rspec What are people using for testing? And further than that what do people test? Just JavaScript? Links? Forms? Hardcoded content? Any thoughts would be greatly appreciated. 回答1: I had the same

Angular 2 with jasmine: test component with injected service

让人想犯罪 __ 提交于 2019-12-20 07:15:07
问题 I can't manage to create a simple jasmine test for my Angular 2 project. This is what I'm trying to do: Component to test (based on a service): @Component({ providers: [AccountService], selector: "account", templateUrl: "app/account/account.component.html", }) export class AccountComponent implements OnInit { public accounts: Account[]; public error: string; constructor(private accountService: AccountService) {} public ngOnInit(): any { this.getAccounts(); } public getAccounts() { this

Angular 2 Observable Service Karma Jasmine Unit Test not working

本小妞迷上赌 提交于 2019-12-20 06:27:02
问题 I am a newbie to Angular 2 and Karma + Jasmine unit tests. I cannot figure out what semantic error I have made in order to make this unit test use the mocked response. In the console, when "expect(items[0].itemId).toBe(2);" is run, it says items[0].itemId is undefined. Would someone be able to help me out or point me in the right direction? Please let me know if you need any additional information. Thanks! item.ts export class Item { itemId: number; itemName: string; itemDescription: string;

AngularJS : Testing factory that returns $http promises

妖精的绣舞 提交于 2019-12-20 05:13:49
问题 Trying to test an angular service that returns an $http GET request and the then handler, but I'm not able to test that the logic actually works inside of the then function. Here is a basic, truncated version of the service code: angular.module('app').factory('User', function ($http) { var User = {}; User.get = function(id) { return $http.get('/api/users/' + id).then(function (response) { var user = response.data; user.customProperty = true; return user; }); }; return User; }); And here is

How to read parameter's value, present in conf.js file of protractor in specs

不羁岁月 提交于 2019-12-20 04:33:09
问题 Ex: conf.js exports.config = { directConnect: false, // multiCapabilities: [{ // browserName: 'firefox' // }, { // browserName: 'chrome' // }, { // browserName: 'internet explorer' // }], specs: ['Specs/spec.js'], seleniumAddress: 'http://localhost:4444/wd/hub', } Specs: it('should be able to select the required organization', function() { Select_Organization.selectOrganization(); //console.log(browser.seleniumAddress); //This is where I need to read the config paramater values, but above is

Unit Testing Angular Observables

自作多情 提交于 2019-12-20 03:15:14
问题 I am new to testing world and I have just started writing unit tests for an existing Angular 2 code. I have a function confirmDelete which returns Obserable<boolean> and internally uses ConfirmationService of PrimeNG to get user's feedback on a popup. Definition of the function is given below: confirmDelete(): Observable<boolean> { let confirmObservable = Observable.create((observer: Observer<boolean>) => { this.confirmationService.confirm({ header: 'Delete Confirmation', message: 'Do you