jasmine

$injector:unpr Unknown provider error when testing with Jasmine

若如初见. 提交于 2019-12-25 09:01:59
问题 So the first time of tackling with unit tests here, I'm trying to initialize the controller of a component using the $componentController mock in angular.mocks. This is my component file. import angular from 'angular'; import ProgressCountdownModule from './progress-countdown/progress-countdown'; import CoverModule from './cover/cover'; import template from './game.tmpl.html'; import './game.css'; import GameController from './game.controller.js'; const GameModule = angular.module('game',

testing .success and .error of service in controller jasmine

筅森魡賤 提交于 2019-12-25 08:18:51
问题 I have a call to service's function in a controller. Below is the code Service (function () { 'use strict'; angular.module('MyApp') .service('MyService', ['$http', function ($http) { return { getMyData: function (extension) { return $http.get('www.something.com'); } }; }]) })(); Controller var getMyData = function () { MyService.getMyData(extension).success(function (results) { //Some functionality here }) .error(function (err, status) { //Some functionality here }); } $scope.Call=function(){

unit testing two service which are in different module with jasmine

痴心易碎 提交于 2019-12-25 08:14:25
问题 I have written some service in angular. Check this PLUNKER. Injecting CommonService, $rootRouter, ModalService in RouteService . Mind the module : CommonService is in mysampleapp.core RouteService is in mysampleapp Also when I try to do this beforeEach(module('mysampleapp.core')); beforeEach(module('mysampleapp')); It gives me some weird ReferenceError: Can't find variable: Map (line 2166) error. Do i need to do the above or am doing it in wrong way?? I am stuck with unit testing RouteService

MongoDB Node.js deleteOne via _id doesn't work on ObjectId

北城以北 提交于 2019-12-25 04:06:50
问题 I'm trying to write test (spec) on a mongo DB wrapper and stumbled on this weird issue. My code, build on top of a thin wrapper of mongodb, expose _id as string to the world but use (convert) them to ObjectId when talking to mongo. I've an helper creating fixtures: var _ = require('lodash'), Promise = require('bluebird'), MongoDb = require('mongodb'); var fixtureData = [ { 'uuid': '1', 'owner': 'A', 'data': 'someData1' }, { 'uuid': '2', 'owner': 'A', 'data': 'someData2' }, { 'uuid': '3',

Can't seem to catch error when using Jasmine toThrowError

旧街凉风 提交于 2019-12-25 04:04:39
问题 I beginning to try jasmine and I want to use the toThrowError() function but my test does not want to succeed. I have one function where I throw an error: test.service.ts test(list:{}){ if(list == null){ throw new TypeError(); } else{ // do something... } } And my test : it('shall throw an error', inject() [ TestService ], ( testService: TestService ) => { let test = testService.test(null); expect(test).toThrowError(TypeError); } ); And my test fails with an Uncaught TypeError (when I call it

Unit testing directive with AngularJS + Jasmine

大兔子大兔子 提交于 2019-12-25 03:53:08
问题 I am a new to unit-testing with jasmine, so iI hope this makes sense and is correct enough to get an answer , I am trying to test an angularJS directive here is my plunker : http://jsfiddle.net/ksqhmkqm/13 in my case i am unable to get the input (id="Montid") value in jasmine here is my angualr code app.directive("monthNext", function () { console.log('massif'); return { restrict: 'A', link: function (scope, element) { element.on('input', function () { var todaysYear = new Date(); var u =

Unit testing directive with AngularJS + Jasmine

流过昼夜 提交于 2019-12-25 03:53:02
问题 I am a new to unit-testing with jasmine, so iI hope this makes sense and is correct enough to get an answer , I am trying to test an angularJS directive here is my plunker : http://jsfiddle.net/ksqhmkqm/13 in my case i am unable to get the input (id="Montid") value in jasmine here is my angualr code app.directive("monthNext", function () { console.log('massif'); return { restrict: 'A', link: function (scope, element) { element.on('input', function () { var todaysYear = new Date(); var u =

Promise is not being handled

佐手、 提交于 2019-12-25 02:58:14
问题 I am writing a unit test for my Angular application using Jasmine with a mock service. However, the promise I am trying to run is not working. Here's the service: CreateItemController = $controller('CreateItemController', { ItemService: { createItem: function(data) { console.log('Service running'); var defer = $q.defer(); defer.resolve('1'); return defer.promise; } The test: it('should create an item', function() { var created = false; $scope.createItem().then(function(response) { // This is

Testacular error: Cannot start chrome [closed]

徘徊边缘 提交于 2019-12-25 01:35:49
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I am going through AngularJS tutorials, and I am stuck on the tutorial for running Testacular tests. I get the following error: Starting Testacular Server (http://vojtajina.github.com/testacular) ------------------------------------------------------------------- info: Testacular server started at http:/

How can i coverage a promise response with Jasmine and Karma

狂风中的少年 提交于 2019-12-25 01:12:10
问题 I have a function that returns and treats a promise, I need to cover the return that is inside then but I don't know how I can do this, I'm currently trying as follows: confirmRemoveUser(user: IUser) { this.modalService .open('Confirma a exclusão do usuário selecionado?', { titleText: 'Confirmando exclusão', confirmButtonText: 'Sim', cancelButtonText: 'Cancelar', closeButtonText: 'Fechar', buttonType: 'danger' }) .result.then( (result: BentoModalConfirmationCloseReason) => { if (result ===