简体   繁体   English

QUnit没有显示我的测试

[英]QUnit not showing my test

I work for a E-Com company that uses .NET MVC with some legacy Webforms applications, augmented by JavaScript. 我在一家E.Com公司工作,该公司将.NET MVC与某些旧版Webforms应用程序结合使用,并通过JavaScript进行了增强。 We currently have no test coverage of any of our JavaScript, as there is quite a lot of it, we thought it best to look in to something to cover that too. 目前,我们没有任何JavaScript的测试内容,因为其中有很多内容,我们认为最好也参考一下内容。

I've been trying to follow some videos on JavaScript Client-Side Unit Testing. 我一直在尝试观看有关JavaScript客户端单元测试的一些视频。 One of them was a Pluralsight course that covered some QUnit. 其中之一是涵盖一些QUnit的Pluralsight课程。

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>QUnit Main Test Suite</title>
    <link rel="stylesheet" href="qunit.css">
    <script src="tests.js"></script>
    <script src="qunit.js"></script>
</head>
<body>
    <div id="qunit"></div>
    <div id="qunit-fixture">test markup</div>
</body>
</html>

Ok so here's my tests.html html file, I've got the qunit.css and qunit.js files in the same directory. 好的,这是我的tests.html html文件,我在同一目录中拥有qunit.css和qunit.js文件。

Here is my tests.js file, something incredibly simple (as per the video I was following) 这是我的tests.js文件,非常简单(根据我关注的视频)

test('my first test', function(assert) {
    var value = "hello";
    assert.equal( value, "hello", "We expect value to be hello");
});

What I get though, when I run up the tests.html file (first code snippet) is this: 但是,当我运行tests.html文件(第一个代码段)时,得到的是:

浏览器中的test.html

I've tried adding in some of the other tests that get provided with the QUnit zip, once included they start showing up, but my test does not. 我试过添加一些其他随QUnit zip一起提供的测试,一旦包含它们便开始出现,但我的测试却没有。 My first thought was perhaps the syntax was incorrect, so I replicated one of the examples that does work when included, this still didn't work for me though. 我的第一个想法可能是语法不正确,因此我复制了其中包含示例的示例,但对我来说仍然无效。

Perhaps I'm misunderstanding something, or have missed something here, any help would be much appreciated. 也许我误会了一些东西,或者在这里错过了一些东西,任何帮助将不胜感激。

Thank you. 谢谢。

Thanks to mparnisari for pointing this out. 感谢mparnisari指出这一点。 This was because of the ordering of my script. 这是因为我的脚本的顺序。 The qunit.js script needed to be included first, then my tests.js file. 首先需要包含qunit.js脚本,然后是我的tests.js文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM