jasmine,teamcity,karma-runner,karma-jasmine , Can one installation of karma be configured to run both jasmine 1.3 and 2.0 tests?


Can one installation of karma be configured to run both jasmine 1.3 and 2.0 tests?

Question:

Tag: jasmine,teamcity,karma-runner,karma-jasmine

We have a TeamCity CI server that needs to be able to execute Jasmine 1.3 and Jasmine 2.0 tests (at different times, on different jobs). It is using the TeamCity Karma integration. My research so far is inconclusive, but it seems like Karma can only have one version of the Jasmine plugin at a time, so it's an either-or proposition. Another way to attack it would be to have two separate installs of Karma on the TeamCity server, but I'm a newbie at both TeamCity and Node, and not sure how this would work out. Any suggestions?

Thanks!


Answer:

Karma looks for the karma-jasmine plugin in the local node_modules folder. The quickest way to switch versions is to simply replace the karma-jasmine folder with the version you want (automated or otherwise) before running your tests, but this has the potential to get messy.

Different installs of Karma is likely the cleaner way. There isn't any issue with having 2 (or as many as you like) local installs of Karma, since they all live under a node_modules folder. In an example directory structure like this, the Karma installation under 1.3 won't know anything about the Karma installation under 2.0.

/tests/
    /1.3/
        /node_modules/
            /karma/
            /karma-jasmine/
    /2.0/
        /node_modules/
            /karma/
            /karma-jasmine/

karma-cli, the module that lets you run karma in a command window from anywhere, however, is one that is installed globally and so has one installation.

If you ran karma start while in the 1.3 folder, karma-cli will execute the Karma under 1.3, which in turn will load the karma-jasmine under 1.3. The same applies when in the 2.0 folder. This gives you the option of maintaining versioned test dependencies.


Related:


Testing client side javascript code with Jasmine


javascript,jasmine
I have javascript code that looks like this: this.ProgressBarUpdater = { poll: function() { setInterval(ProgressBarUpdater.request, 5000); }, request: function() { $(".progress_bar_updater[data-url]").each(function(i, elem) { url = $(elem).data("url"); $.getJSON(url, function(data) { if (isFinished(data)) { location.reload(); }; $.each(data, function(key, val) { updateProgressBar(key, val); }); }); }); } }; isFinished = function(obj) { var...

Order of independent Build Configs in TeamCity


teamcity
I'm migrating our build system over to TeamCity and, because we have quite long build times, I'm trying to make good use of parallelism in build configurations. If two configs can run in parallel they are obviously not dependent on each other. However there are some cases where, if two...

Using Teamcity to deploy css into git repository


git,tfs,teamcity
I have a git repository set up for our angular project. The styling for the website is being worked on by a separate front end team who will be checking in their work to a TFVC repository in TFS. We are using Teamcity for CI. I would like to be...

Jasmine SpyOn haveBeenCalled on function reference don't work (Angular)


javascript,angularjs,jasmine
In my Angular controller I have implemented a listener, that call a function by reference: $scope.$on('$destroy', vm.popoverChooseProfile.remove); I have implemented a test with Karma and Jasmine. it('should remove the popover the scope is destroy', function() { var vm = createController(); vm.popoverChooseProfile = MOCK_POPOVER; spyOn(vm.popoverChooseProfile, 'remove'); $scope.$destroy(); expect(vm.popoverChooseProfile.remove).toHaveBeenCalled(); }); The test...

Jasmine Unit Tests Unexpected this Reference


javascript,jasmine,jasmine-node
I am trying to test a fairly simple JavaScript function in Jasmine, however the first statement is throwing an error for being undefined. myClass.prototype.functiontoBeTested = function() { var x = this.method() ... } The above throws an error in Jasmine as method is not a function and is undefined. The...

“Test Finished” handler in Jasmine?


jasmine
How to add a Test-Finished handler to a jasmine test? I need it to deallocate resources consumed by the test. I'm using the very latest version of jasmine 2.3.1 with Node JS....

Mocking Angular $window in unit test cases


javascript,angularjs,unit-testing,typescript,jasmine
I have been trying to unit test my angular custom service written in Typescript. The service reads a global variable defined on the Window object. I have made it promise, so that in future I can make a AJAX call to get this information. Here is my stripped down service:...

Jasmine spyOn with multiple returns


javascript,angularjs,coffeescript,jasmine
I would like to test my angular application with Jasmine. So I created some tests, most of them work fine. But, one of my functions require the user to fill in an prompt. Tests can not fill this prompt, so I mocked them with spyOn(window,'prompt').and.returnValue('test'). This works, but only once....

How to write jasmine test for following angular service which uses API and call backs


angularjs,callback,jasmine
In my AngularJS application, I am having trouble figuring out how to unit test the following code: This is the service being used by my test controller: angular .module('web.template') .factory('testService', testService); testService.$inject = ['$http']; function testService($http) { return { getTestDatas: function (callback) { var data = { 'testParams': "test" };...

Why is address undefined in my app?


node.js,express,jasmine,supertest
I have a simple express app: var express = require('express'); var path = require('path'); var app = express(); exports.app = app; var index = require('./routes/index'); app.use(express.static(path.join(__dirname,'client/dist/'))); app.get('/', index.get); function start(){ var port = process.env.PORT || 8080; app.listen(port, function(){ console.log('app is running on port: ' + port); }); }; exports.start =...

How do I support jasmine and es6 syntax in Visual studio Code?


jasmine,ecmascript-6,vscode
Question where can I find and how do I add support for jasmine and es6 syntax in Visual studio code? ...

Protractor in Node: How do I order my tests to run synchronously?


node.js,selenium,jasmine,protractor
I'm wondering how to execute multiple "describe" blocks in synchronous order? describe('Go To Home Page', function () { browser.ignoreSynchronization = true; it("Url should be on Login Page", function () { browser.get(HomePageUrl).then(function () { browser.wait(urlChanged(loginPageUrl), 2000).then( function (newurl){ var url = browser.getCurrentUrl().then(function (url) { expect(url).tobe(loginPageUrl); //I know I'm at Login page...

How to call browser.get only once in a script?


javascript,angularjs,automation,jasmine,protractor
I am new to protractor, right now I am putting browser.get(URL) within the first 'it' statement and then for my afterEach statement I make the browser go back to the homepage. I am wondering if there's a better place to put the browser.get statement to make my tests more module?...

Spy on a service method call using jasmine Spies


angularjs,unit-testing,jasmine,karma-runner,karma-jasmine
I have the following controller ViewMeetingCtrl.js (function () { 'use strict'; angular.module('MyApp').controller('ViewMeetingCtrl', ViewMeetingCtrl); ViewMeetingCtrl.$inject = ['$scope', '$state', '$http', '$translate', 'notificationService', 'meetingService', '$modal', 'meeting', 'attachmentService']; function ViewMeetingCtrl($scope, $state, $http, $translate, notificationService, meetingService, $modal, meeting, attachmentService) { $scope.meeting = meeting; $scope.cancelMeeting = cancelMeeting; function cancelMeeting(meetingId,...

Expect fails for verifying inner HTML


jquery,selenium,testing,jasmine,protractor
For some reason my assert in protractor fails, what i'm trying to do is get the innerHTML (text) from an element: var stuff = $('css').html(); expect(stuff).toBe("Inner HTML Text here"); I verified that the $().html() yields the text i desire on the console, what is wrong with my expect statement? TypeError:...

Accessing scope.variables inside a function in jasmine


angularjs,unit-testing,jasmine,karma-runner,karma-jasmine
I am trying to get the assert the value of the $scope.buttonDisable variable which is inside the save(). here is the test case describe('EditMeetingCtrl.save()', function () { var $rootScope, scope, $controller , $q , state , controller ; var companyService , meetingService ; beforeEach(angular.mock.module('MyApp')); beforeEach(angular.mock.inject(function (_$httpBackend_, _companyService_ , _meetingService_ )...

Mock the value of a service inside directive's unit test


angularjs,unit-testing,jasmine,karma-runner
Inside my directive's instantiation I have a call to a method that returns some data: data = myService.getData() and later in the code I am doing something = data[id] In karma I have an error, cannor read id of undefined, meaning that data is undefined. I tried to mock the...

Why does Jasmine toEqual return true when comparing empty array with empty object?


javascript,tdd,jasmine
I get why the following returns false... expect({}).toBe({}); And I get why the following returns true... expect({}).toEqual({}); But why is the following true? expect([]).toEqual({}); ...

Trying to spy (Jasmine) on Array.prototype methods causes stack overflow


javascript,jasmine,prototype,spy,testem
This is pretty odd. Using the testem runner with jasmine2 and the following spec executes (though it correctly flags that there are no expectations): describe('Spying on array.prototype methods', function(){ it('should work this way', function(){ spyOn( Array.prototype, 'push' ).and.callThrough(); // expect(1).toBe(1); }); }); However, add an expect (any expect!) and it...

ReferenceError: module is not defined (angular js unit testing with Jasmine)


angularjs,unit-testing,jasmine,karma-jasmine
I found a lot of questions about this, but the answers didn't work for me. I have a small controller in angular js. It works fine, and I wanted to start testing. I downloaded Jasmine standalone from here. I put my controller in the "src" folder, and another js file...

How to solve error about “invalid selector” when using “if statement” in Protractor JS?


javascript,angularjs,node.js,jasmine,protractor
I want to use an invisible element as a condition if it present do X and else do Y. I've already tried to use by the class of this element as the locator and the ng-model and binding of him but none of them is worked :/ Please your assistance...

How to define WIX agent requirment in TeamCity?


msbuild,wix,teamcity
I have add a WIX installer project to solution in Visual Studio 2013. The project is built with every commit on TeamCity. There are several build agents connected to TeamCity cloud, but only some have WIX installed. Usually I would add the build agent requirement, so only the computer with...

Javascript Regex: “Any word” pattern


javascript,regex,testing,jasmine,karma-jasmine
In a Jasmine test, I am trying to set this match to fit with expressions like: 'Request <any_word> for <any_word> - Open actions menu'. However, it's not being possible with this line, but Javascript doc says that \\w is the regex for any word: expect(item.getIconToolTip()).toMatch('Request \\w for \\w - Open...

Is it possible for jasmine to access the scope methods defined in an angular directive controller?


angularjs,jasmine,angular-mock
I'm trying to unit test a directive like the one below. I want to be able to call the functions defined in the directive's controller ($scope.save), but my tests can't seem to access that scope at all. I also tried isolateScope(), but that didn't return the inner $scope object like...

Team city template missing


teamcity
I was going to reuse teamcity configuration to new environments. Looks like the configuration is based on a template, but actually there is no clickable link to teamplate and I can't find it in the root project. I was thinking that the template was deleted but team city doen't allow...

Setting global variables in jasmine for angularjs


javascript,angularjs,jasmine,karma-jasmine
I have an angular application with some global environment variables defined in an env.js file: (function(sp) { 'use strict'; pk.env = pk.env || {}; // localhost pk.env.baseUrl = 'http://localhost:8080/'; })(typeof exports === 'undefined' ? (this.pk = this.pk || {}) : exports); These variables are used in multiple factories to make...

TeamCity checkout GitHub repo to specific absolute path


github,path,teamcity,git-checkout
My TeamCity VCS Root step needs to checkout a specific GitHub repo to a specific absolute folder on the agent ( Windows server ) : c:\github\{organization}\{repo} I'm not understanding how to construct my checkout rule to do this. By default, checkout rules are relative to the checkout dir which is...

Jasmine beforeEach not called


javascript,unit-testing,jasmine,jasmine-jquery
Just starting with Jasmine and following the instructions on the Jasmine website for async testing I notice the beforeEach function is never called. Any idea why not? I don't find any hints relevant anywhere on the web. Thanks. Code The code is really simple: describe("Testing test.php", function() { it ("Gets...

_foo is not a function, when called from init method in Jasmine


javascript,jasmine
I am testing a controller which has a private method _init() called during its instantiation. It does some service calls (which are mocked out) and calls some private helper functions within the same controller. It all works great up until within a success block of a service call it tries...

Node.d.ts issues errors using typescript compiler, how do I fix?


node.js,visual-studio,typescript,jasmine,protractor
I have a project that's a NODE console application project using Visual Studio 2013. When I compile the solution I'm getting typescript errors as follows: Typescript wants a semicolon after export interface ReadableStream extends EventEmitter { readable: boolean; read(size?: number): string|Buffer; //Like this ----> read(size?: number): string;|Buffer; Which means I...

how to mock $state.params in jasmine unit testing


angularjs,unit-testing,jasmine,karma-runner,karma-jasmine
I have the following controller EditMeetingCtrl.js (function() { 'use strict'; angular .module('myApp') .controller('EditMeetingCtrl', EditMeetingCtrl); EditMeetingCtrl.$inject = ['$rootScope', '$scope', '$state', '$http', '$translate', 'meetingService', 'companyService', 'notificationService', 'meeting']; function EditMeetingCtrl($rootScope, $scope, $state, $http, $translate, meetingService, companyService, notificationService, meeting) { $scope.meeting = meeting; $scope.companyId = $state.params.companyId; $scope.save = save; function...

Injecting custom factory in jasmine test


angularjs,unit-testing,jasmine
I tried to inject a factory to my controller in jasmine test like in AngularJS - unit testing a factory that has dependencies When I $provide a factory in the test, I would expect the controller to use the provided factory. But the console.log still prints 'real value'. I don't...

Protractor, Done and Expect, why do we need wait?


selenium,selenium-webdriver,jasmine,protractor
I thought Done would make things run synchronously, meaning after I click a link, the click call back would happen after the click, apparently not as this doesn't work. browser.ignoreSynchronization = true; var firstURL = "https://www.google.com/?gws_rd=ssl"; describe("test", function () { browser.get("http://www.google.com"); it("Should be on google url", function () { expect(browser.getCurrentUrl()).toBe(firstURL);...

adding a utility namespace in JasmineJS


javascript,jasmine
I'm starting to modify a JasmineJS test suite, and there are some logging calls I want to clean up. Specifically I want to add a utilities.js file in the directory of the test spec... and reference it throughout all my test specs. There are now two test specs testSuite1.spec.js and...

REST API of Teamcity for initiate a build


java,teamcity
Can anybody suggest how TEAMCITY RestAPI can used for trigger a build for a particular project availble in bitbucket/mercurial repository and getting the result of the build ,that is jar/war file .

Jasmine resolving promises after calls but before expects


jasmine
For testing my controller I have some services mocked out using $q injection. These will reject or resolve the promises where appropriate. My tests rely on spies to monitor if functions have been called. I've found all over that I need to call $rootScope.$digest() which works if I include it...

How to fetch the Value of Teamcity Configuration in java?


teamcity
I have a piece of java code where I have to display the Teamcity build configuration name. This piece of code will be executed in one of the steps configured for the configuration. can we read value of the env variable %env.TEAMCITY_BUILDCONF_NAME% set in Teamcity configuration settings and use or...

Stubbing an angular service with a function that returns a promise using sinon


angularjs,jasmine,sinon
I'm trying to test a controller that calls a method on a service. The service method returns a promise, and the controller immediately invokes .then() inline after calling the service method. I'm trying to stub the service using sinon and Jasmine keeps throwing an error saying that then is undefined...

Installing Teamcity build agent as a user: failed to install the service. selected account does not have enough rights


automation,continuous-integration,teamcity,build-agent
I want to install a TeamCity BuildAgend as a user. When entering my user credentials here: I always get this error: NOTE: My account (user) is Administrator with full permission! How can I do this?...

How to test a meteor method that relies on Meteor.user()


testing,meteor,jasmine
I am trying to determine the best way to test my code and am running into complications from every direction I've tried. The basic code is this (though far more complex due to several layers of "triggers" that actually implement this): Client populates an object Client calls a meteor method...

spyOn listener watch function not working


javascript,angularjs,jasmine,karma-jasmine,angularjs-watch
When I try to spyOn the listener function of a $scope.$watch, is like never call the spyOn http://jsfiddle.net/b8LoLwLb/1/ My controller angular.module('angularApp') .controller('MainCtrl', function ($scope) { $scope.name = ''; this.changeName = function () { console.log('the name has change to ' + $scope.name); }; $scope.$watch('name', this.changeName); }); My test describe('Controller: MainCtrl', function...

How do I set up a TeamCity build job to execute a maven job with no pom


maven,teamcity
We have an in-house developed MOJO that generates content and doesn't require you to have an existing project or POM. Think of the maven archetype plugin, where you can just run mvn [mojo]:[goal] and have maven just execute that goal without a POM. This MOJO connects to a specific database...

Testing an Angular directive using Jasmine 2's spyOn


angularjs,unit-testing,jasmine,spyon
I have an AngularJS directive I'm trying to test with Jasmine 2. Here's a Mock service that I have defined at the beginning my test. var Note = { getNotes: function (type, id) { console.log('I have been called') }, save: function () {} }; And here's my test: beforeEach(function ()...

Continuous deployment and running with TeamCiy


.net,continuous-integration,teamcity,exe,continuous-deployment
I have a project that is built into an executable. Some kind of server. And a Team City as CI. I configured Team City to automatically build my sources. I would like to achive the following steps: Sources are built by Team City when someone commits into repo. (done) Built...

How to invoke spyOn on a scope function


angularjs,unit-testing,jasmine,karma-runner,karma-jasmine
I have the following jasmine spec. describe('ViewMeetingCtrl', function () { var $rootScope, scope, $controller , $q ; beforeEach(angular.mock.module('MyApp')); beforeEach(inject(function ($rootScope, $controller ) { scope = $rootScope.$new(); createController = function() { return $controller('ViewMeetingCtrl', { $scope: scope, meeting : {} }); }; })); it('the meeting type should be equal to an object',...

How to use Jasmine and CucumberJS with Protractor


angularjs,testing,jasmine,cucumber,protractor
I'm looking to use Protractor, CucumberJS, and Jasmine for testing my project. How do I use both Jasmine and CucumberJS with Protractor? Here's the project setup I've created: /path/to/myproj/protractor.conf.js exports.config = { seleniumServerJar: 'node_modules/protractor/selenium/selenium-server-standalone-2.45.0.jar', specs: [ 'features/*.feature' ], baseUrl: 'http://localhost:8080', multiCapabilities: [ { 'browserName': 'chrome' } ], allScriptsTimeout: 380000, getPageTimeout:...

Pass on branch name to a script in teamcity


teamcity,teamcity-9.0
I have a python script that runs as build step in teamcity 9.0. Now I need to know the branch name from which the build is triggered. I could use %teamcity.build.branch% to get the branch name. But I need it to be passed on to my script so that I...

Halt javascript execution until promise is resolved


javascript,angularjs,node.js,jasmine,protractor
I have a specific use case where in test code I want to fetch a tables headers (async) and then dynamically create getters on a javascript object. The syntax that I would like to use in my test is antenneTable.row(0).getAzimut();. The problem I am having is that antenneTable.row(0); returns a...

Testing Meteor packages with Velocity?


meteor,jasmine,meteor-velocity
Velocity is an amazing testing framework for Meteor and I am currently using it to test my application code. Now I added a local package to the app, but I don't know how (or if) I can test the package with Velocity, too. I would like to drop tinyTest in...

jasmine spyOn on javascript new Date


javascript,angularjs,unit-testing,jasmine,karma-jasmine
I am unit testing the my client code in angulajs and i understand this code means var newdate = new Date(2013,6,29); spyOn(Date.prototype, 'getTime').and.callFake(function() { return newdate; }); we mockout the getTime() methode of the Date object. but i want to mock out the new Date() instead. for example the code...