jasmine

jasmine-node shows error when ran from command prompt

徘徊边缘 提交于 2019-12-06 08:46:20
问题 Installed jasmine-node using this: sudo npm install jasmine-node -g It is successful and shows: /usr/bin/jasmine-node -> /usr/lib/node_modules/jasmine-node/bin/jasmine-node jasmine-node@1.14.3 /usr/lib/node_modules/jasmine-node ├── underscore@1.6.0 ├── mkdirp@0.3.5 ├── walkdir@0.0.7 ├── jasmine-reporters@2.0.0 ├── coffee-script@1.7.1 ├── requirejs@2.1.14 ├── jasmine-growl-reporter@0.0.3 (growl@1.7.0) └── gaze@0.3.4 (minimatch@0.2.14, fileset@0.1.5) But when I try to run this: $ jasmine-node

How to jasmine.getenv().currentspec with jasmine 2.3

梦想与她 提交于 2019-12-06 08:35:14
问题 I want to get the passed or failed status of my test after each spec is executed: var passed = jasmine.getEnv().currentSpec.results().passed(); if (!passed) { browser.takeScreenshot().then(function(png) { writeScreenShot(png, filename, path); }; } but jasmine.getEnv().currentSpec is returning undefined , I am using Jasmine 2.3 how can I get the currentSpec with Jasmine 2.3 回答1: It's likely that you are calling this from outside of the current spec. jasmine.getEnv().currentSpec will be null if

Jasmine unit test for angular service In controller

可紊 提交于 2019-12-06 08:28:52
I'm new to jasmine framework. I've gone through some tutorials and learned and started writing unit tests. 'facing one issue here is the description. I have a controller where i can invoke a service call to get the data. See the code below. $scope.getEmpInfo = function() { EmpService.getInfo($scope.empid) .then(function(data) { $scope.empData = data; $scope.populateEmpData($scope.empData); }, function(reason) { //do nothing } } Now, i want to write a unit test for the above method. Im able to make a spy on serice using promise but i wasnt able to spy $scope.populateEmpData() . here is my test

Getting “Unexpected request” error when running Karma unit test in an AngularJS app

。_饼干妹妹 提交于 2019-12-06 08:13:48
I'm trying to write a unit test for a controller which fetches article details using $http service. Controller: .controller('ArticleDetailCtrl',function($scope, Article, $routeParams, API_URL, ARTICLE_URL, $http, $sce){ $scope.url = API_URL + ARTICLE_URL + '/' + $routeParams.articleId; $http.get($scope.url).then(function(response) { //console.log(response.data); $scope.heading = response.data.Headline; $scope.rawBody = response.data.Body; $scope.body = $sce.trustAsHtml($scope.rawBody); $scope.image = response.data.Assets[0].URL; }); }); Unit test: 'use strict'; describe('Controller: Article',

Chutzpah coverage result smaller than 100% (due to private methods?)

限于喜欢 提交于 2019-12-06 07:54:19
I use Chutzpah to test my JavaScript test coverage. Here is an example for the coverage result when I run a single test file referenceFigureEdit.spec.js : I would expect the coverage to be 100% but it is only 91.07%. Clicking on the first line I can inspect my tested code in detail. Lines that are "not covered by the test" are highlighted: Question A : How can I tell Chutzpah that those methods have actually been executed or tell Chutzpah to not include those lines in the coverage result? Are there some restrictions on where/when code has to be executed to be part of the successful coverage? I

How to mock socket.io with Angular and Jasmine

心已入冬 提交于 2019-12-06 07:45:42
I'm having trouble figuring out how to correctly mock Socket.io in an Angular application using Jasmine and Karma. Here are the files found in karma.conf.js : 'bower_components/angular/angular.js', 'bower_components/angular-mocks/angular-mocks.js', 'bower_components/angular-ui-router/release/angular-ui-router.js', 'bower_components/angular-socket-io/socket.js', 'bower_components/socket.io-client/socket.io.js', 'bower_components/angular-socket-io/mock/socket-io.js', 'public/javascripts/*.js', 'ng_tests/**/*.js', 'ng_tests/stateMock.js' Here is how my controller looks: var lunchrControllers =

Why does my Jasmine spec think my Angular module is undefined

微笑、不失礼 提交于 2019-12-06 06:50:58
Why does my Jasmine spec think my Angular module is undefined? I've added a line of code setting a boolean to true below the actual module code, and then I console.log it from within the spec, and it indicates true. I've also tried changing the module so it is not an ultra-scope (my term) or IIFE, but that has no effect. The gist of the error message is Expected undefined to equal <jasmine.any(Object)>. Spec runner: <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Angular Spec Runner</title> <link rel="shortcut icon" type="image/png" href

protractor timeout after 30000msec

孤街浪徒 提交于 2019-12-06 06:39:30
问题 I am tryin to integrate protractor e2e tests in my cruisecontrol I am using the following testspec: describe('index', function () { var ptor; it('should have a title', function () { browser.get('http://juliemr.github.io/protractor-demo/'); expect(browser.getTitle()).toEqual('Super Calculator'); }); it('Check google', function () { browser.driver.get('http://www.google.com'); }) }); When I run this spec though the command line works fine. However when I run it as a nant target in the build

Protractor expectation that element is eventually present

℡╲_俬逩灬. 提交于 2019-12-06 06:11:30
问题 Is there a way to have an expectation that an element is eventually on the page? e.g. a way for browser.wait(protractor.ExpectedConditions.presenceOf(element(by.partialLinkText('Continue'))), 1000, 'Unable to find continue link'); to fail with an expectation error instead of a timeout? Essentially a way to have a isEventuallyPresent() instead of isPresent() in the line below expect(element(by.partialLinkText('Continue')).isPresent()).toBe(true); For reference, I'm using browser

spying upon a global function using jasmine-node

假装没事ソ 提交于 2019-12-06 05:52:25
I am using jasmine-node to do unit testing on javascript code. I have a number of global functions which I would like to spyOn and allow the call to make it though to the original implementation. See the code below as an example. For a reason I cannot explain, I am seeing an error "globalFunction() method does not exist". Can someone tell me why jasmine is not able to find this globalFunction method which I understand to be in global scope. I appreciate the help var globalFunction = function() { console.log('globalFunction'); }; describe("A Global Function", function() { jasmine.getEnv()