JasmineJs is a great framework for testing JavaScript code.
We'll discuss here how to integrate it with other amazing products: ReSharper 7 & TeamCity.
Download
You can download standalone example here(with additional files to run tests from ReSharper & TeamCity).
This package contains two folders: SpecRunner and YourWebSite. We’ll need them later.
JasmineJs + ReSharper 7 = Friends
To run client-side tests without dependency on your browser we can use PhantomJs WebKit.
Put files from downloaded SpecRunner folder somewhere in your solution.
For example, in my solution these files are located in MyProject/Testing/Client/ folder.
Now we can configure ReSharper to use PhantomJs:
For example, in my solution these files are located in MyProject/Testing/Client/ folder.
Now we can configure ReSharper to use PhantomJs:
However, note that we don’t need to include JasmineJs scripts, because ReSharper has it’s own inside.
JasmineJs + TeamCity = Friends
Preparing project for running JS-tests from TeamCity
Put downloaded YourWebSite/lib/ folder in Scripts/Jasmine/ folder of your Web project.
Put downloaded YourWebSite/SpecRunner.htm file in the root of your Web project.
For example:
- JasmineJs scripts(ReSharper doesn’t need them, but TeamCity does);
- Source files to be tested + their dependencies;
- Spec files with tests;
- jasmine.teamcity_reporter.js
Example of SpecRunner.htm:
Configuring TeamCity for running JS-tests from our project
We need to create additional Build Step in TeamCity:
Note, that we specify Working directory as Testing/Client/ folder of our solution(where we put downloaded files from SpecRunner folder).
Cool!
ReplyDelete