Jasmine test runner integration with visual studio and a build process - javascript

how do you integrate Jasmine's test runner with Visual Studio and your custom build process ? I've read an article at codebetter that shows how to achieve this task using FubuMVC and a few other components but I was wondering if you can recommend any alternatives ?
So how do you do that at your workplace ?
Many thanks,
Tomek

Take a look at Chutzpah (http://chutzpah.codeplex.com/). It has integrated test runners and command line options for running Jasmine or QUnit tests. Behind the scenes it uses PhantomJS, a headless browser, to load up tests and run them.

I know this is a year old, but FYI, I noticed that a new AngularJS SPA Template project (ASP.NET) in Visual Studio 2013 includes Jasmine (SpecRunner.cshtml). The AngularJS SPA Template is an extension to VS2013 (and can be installed on VS2012 and VS2010).
So it is there now, go to extensions and updates in VS to find it!

Related

Testing CShtml files in MVC project using jasmine

I would like to test my javascript code (that includes jQuery library) that is in my CShtml file at a MVC project that runs on visual studio 2015.
I know that testing on js files can be done using jasmine.
Can I test a cshtml file using jasmine?
Where can i find a good tutorial on the subject?
You could use Chutzpah. It is a JavaScript test runner which works fine with Jasmine. It is available as a plug-in for Visual Studio and is easy to setup. It also integrates with the Test Explorer of Visual Studio. The wiki explains the features and how it works.
The following thread can help you:
Setup Jasmine Test Framework on MVC 5
This is a good read too

Integration testing with Karma

Until now, I've done all my testing with just Jasmine and jQuery to automate the browser. I am starting to explore Karma but it seems to be set up only for unit tests that involve loading HTML fragments as test fixtures and I find no way to load a whole web page. Am I missing something or is this simply the wrong tool for what I am trying to do?
From the karma FAQ's section:
Can I use Karma to do end to end testing?
Karma has primarily been designed for low level (unit) testing. If it's an AngularJS app, you can use Karma with the karma-ng-scenario plugin. However, we recommend Protractor for high-level testing.
Typically, loading a whole web page goes beyond the scope of single units of code: you need to spin up a browser, load the page and make your actions and assertions. End-to-end testing frameworks like Protractor, Nightwatch.js or Webdriver.io might be more suitable for this specific case.
You can do integration testing using the following toolchain:
Karma ➔ Mocha ➔ Mocha-CasperJS ➔ CasperJS.
Check out the mocha-casperjs package.

Javascript project templates Win App store

Short question, where to find the Javascript templates for Windows Apps?
As described in the follow link:
Javascript project templates for store apps
Tried Googling and trying to search inside Visual Studio with no avail (JS templates are not installed by default). Searching Online through Visual Studio returns nothing of value.
Using Visual Studio Express Update 2.
For some reason a fresh clean install did install all the templates except for the JavaScript ones.
A (lengthy) repair of Visual Studio 2013 Express did the trick!

What is the correct way to test javascript with unit AND integrations tests, using Visual Studio and Team City?

I have got javascript tests running in visual studio using Resharper and Jasmine. It all works fine. Now however I want to run an integration test. After looking into this I just can't work out whether I should be using Karma or PhantomJs or both? And whether they link to resharper?
I then have to run all my tests on the continuous integration server using Team City. Doesn't seem like there is a clear logical way to architect front end testing from dev right through to the CI server.
For example do I really need to use Karma locally and on the CI server? I don't want to because it is not baked into visual studio and I will have to keep opening the command line and running my tests manually. This will annoy other developers and they won't bother running them I imagine. Help!
We are using Team City by the way....
Neither of these test runners are connected to Resharper in any form. I don't think there is a one and only "correct" way of running Jasmine tests in TeamCity currently - for all approaches I am aware of there is a bit of assembly required.
Personally I am using a combination of PhantomJS and the Jasmine TeamCity Reporter which works like this:
Get a list of unique test URLs from server - each of these test suites will use the Jasmine TeamCity Reporter to log results
for each test URL dynamically generate a test JS file to be used for phantom and write it to disk
use PhantomJS to run the JS file which now will load the test suite page and its test result will be written to console where they are picked up by TeamCity.

Easy way to integrate Jasmine JavaScript unit testing with TFS Build CI

I've been writing JavaScript unit tests using Jasmine. However, those tests run inside a browser, not as part of MSTest.
I want my TFS Continuous Integration builds to break when a JavaScript unit test fails. I know there is a solution for this in Visual Studio 2012, but I'm on 2010 (and will be for a long time in the future probably).
Is there an easy way to integrate Jasmine based JavaScript unit tests with TFS Build?
The Chutzpah test runner enables you to run your QUnit and Jasmine JavaScript unit tests from the command line or Visual Studio.
Therefore you should be able to integrate it into your TFS build via the InvokeProcess activity.
I'd use nodejs + jasmine-node, but you can also look at http://phantomjs.org/ with a junit reporter. Jasmine-node provides a junit reporter with the --junitreport output. You might also look at the TFS Build Extensions (http://visualstudiogallery.msdn.microsoft.com/2d7c8577-54b8-47ce-82a5-8649f579dcb6/view/Discussions/) and the activities in there. It includes a xml transform for JUnit to TRX (test results xml) which can be pushed into TFS.

Categories

Resources