Alex
Alex

Reputation: 892

How to unit test javascript embedded in razor view with visual studio

Is it possible to unit test javascript that is embedded in a razor(.cshtml) view with Visual Studio Test Explorer? I briefly looked at Chutzpah, but it looks like the javascript has to be separated into its own file.

Upvotes: 2

Views: 812

Answers (1)

beautifulcoder
beautifulcoder

Reputation: 11320

You have to reference it some way in Chutzpah. They only way to do that is by putting it in a separate file.

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

Tight-coupling JS and HTML code is no way to write testable code.

Upvotes: 1

Related Questions