在MVC 5上安装Jasmine Test Framework [英] Setup Jasmine Test Framework on MVC 5

查看:144
本文介绍了在MVC 5上安装Jasmine Test Framework的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS2013的MVC 5项目中从nuget设置Jasmine测试框架时遇到问题。

I am having problems setting up the Jasmine Test Framework from nuget in my MVC 5 project in VS2013.

运行SpecRunner时,我总是收到错误消息。 cshtml文件。它一直说资源无法找到,但它没有指定哪一个。

I always get an error message when I run the SpecRunner.cshtml file. It keeps saying that the resource cannot be found but it doesn't specify which one.

任何人都知道如何正确设置一个独立的SpecRunner.cshtml(无需经过索引页)?

Anyone know how to properly setup a standalone SpecRunner.cshtml (without needing to go through the index page)?

以下是我目前在SpecRunner.cshtml中的内容

Here is what I currently have in my SpecRunner.cshtml

@{
  Layout = null;
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>Toolkit - Tests</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="shortcut icon" type="image/png" href="/Content/jasmine/jasmine_favicon.png">
    <link rel="stylesheet" type="text/css" href="/Content/jasmine/jasmine.css">
    <script type="text/javascript" src="/Scripts/jasmine/jasmine.js"></script>
    <script type="text/javascript" src="/Scripts/jasmine/jasmine-html.js"></script>
    <script type="text/javascript" src="/Scripts/jasmine/boot.js"></script>

    <script src="~/Scripts/AngularJS/angular.js"></script>
    <script src="~/Scripts/AngularJS/angular-mocks.js"></script>
    <script src="~/Scripts/AngularJS/angular-ui-router.js"></script>

    <!-- include source files here... -->
    <!--<script type="text/javascript" src="/Scripts/jasmine-samples/SpecHelper.js"></script>
    <script type="text/javascript" src="/Scripts/jasmine-samples/PlayerSpec.js"></script>-->
    <script src="~/Scripts/MyAngularJS/app.js"></script>
    <script src="~/Scripts/MyAngularJS/controllers.js"></script>

    <!-- include spec files here... -->
    <!--<script type="text/javascript" src="/Scripts/jasmine-samples/Player.js"></script>
    <script type="text/javascript" src="/Scripts/jasmine-samples/Song.js"></script>-->
    <script src="~/Scripts/MyAngularJS/controllersTest.js"></script>

    <script>
    (function () {
        var jasmineEnv = jasmine.getEnv();
        jasmineEnv.updateInterval = 1000;

        var htmlReporter = new jasmine.HtmlReporter();

        jasmineEnv.addReporter(htmlReporter);

        jasmineEnv.specFilter = function (spec) {
            return htmlReporter.specFilter(spec);
        };

        var currentWindowOnload = window.onload;

        window.onload = function () {
            if (currentWindowOnload) {
                currentWindowOnload();
            }
            execJasmine();
        };

        function execJasmine() {
            jasmineEnv.execute();
        }

    })();
    </script>
</head>

<body>
</body>
</html>


推荐答案

您可以使用 Chutzpah 。它是一个JavaScript测试运行器,可与Jasmine一起使用。它作为Visual Studio的插件提供,易于设置。它还与Visual Studio的Test Explorer集成。 wiki 解释了这些功能及其工作原理。

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.

这篇关于在MVC 5上安装Jasmine Test Framework的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆