Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
ReSharper Essentials

You're reading from   ReSharper Essentials Make your Microsoft Visual Studio work smarter with ReSharper.

Arrow left icon
Product type Paperback
Published in Feb 2014
Publisher Packt
ISBN-13 9781849698702
Length 124 pages
Edition Edition
Arrow right icon
Author (1):
Arrow left icon
Lukasz Gasior Lukasz Gasior
Author Profile Icon Lukasz Gasior
Lukasz Gasior
Arrow right icon
View More author details
Toc

Testing JavaScript


ReSharper can also support you in writing unit tests in JavaScript.

Running JavaScript unit tests

There are many different frameworks that allow you to write unit tests for JavaScript. The most popular ones are QUnit and Jasmine. What is really cool is that both are supported by ReSharper. It means that you can run them in the same way that you run C# tests written in NUnit or other frameworks. Very nice, isn't it?

A sample unit test written in QUnit is shown in the following screenshot:

As you can see, ReSharper recognizes and marks unit tests in the same way as they were with NUnit. Even the available menu options are the same.

When you write unit tests in JavaScript, you need to add a reference to the file that contains the tested methods. You can see a sample reference in the previous screenshot, which looks as follows:

/// <reference path="Utilities.js"/>

ReSharper needs to know where the code that you are testing is placed. You do the same in C# but with the using...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image