gpt4 book ai didi

qunit - 作为 TFS 构建的一部分运行 html QUnit 测试会在测试上下文之外给出有关 start() 的错误

转载 作者:行者123 更新时间:2023-12-01 19:16:06 27 4
gpt4 key购买 nike

使用 instructions here ,我正在尝试通过 chutzpah 配置 QUnit 测试

error

错误是:

Error: Error: Error: Called start() outside of a test context while already started
at start in https://cdnjs.cloudflare.com/ajax/libs/qunit/1.18.0/qunit.min.js (line 11)
at startQUnit (line 12)
at onPageLoaded (line 16)

测试的格式如下:

module('Product - Somme Condition', {
setup: function () {
$('#Markup').append('<div>...</div>');
},
teardown: function () {
$('#Markup').empty();
}
});

test('Given When Then', function () {
//..
});

HTML runner 设置如下:

<!DOCTYPE html>
<html>
<head>
<title>Product Test Runner</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/qunit/1.18.0/qunit.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/qunit/1.18.0/qunit.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/blanket.js/1.1.4/blanket.min.js"></script>
<script src="../../BuildFiles/someDependency.js"></script>
<script src="../../BuildFiles/product.js"></script>
<script src="../Tests/Product/ProductTest.js"></script>
</head>
<body>
<form>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<div id="Markup"></div>
</form>
</body>
</html>

该步骤设置为 Visual Studio 测试步骤:

test step
(我会在工作后将其更改为 *.html,在一个文件上测试更容易,所有文件的行为都相同并且结构如上)

测试在日志中显示为“已通过”,但构建步骤尚无定论。我怎样才能使它变绿?

build steps

-- 编辑

使用 example QUnit test ,

即,

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>QUnit Example</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.2.1.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="https://code.jquery.com/qunit/qunit-2.2.1.js"></script>
<script src="tests.js"></script>
</body>
</html>

通过以下方式调用 chutzpah:

chutzpah.console.exe C:\Dev_Scratch\testRunner.html

错误输出为:

Chutzpah console test runner (64-bit .NET 4.0.30319.42000) Version 4.3.4.0 Copyright (C) 2016 Matthew Manela (http://matthewmanela.com).

Error: Error: Called start() while test already started running at start in https://code.jquery.com/qunit/qunit-2.2.1.js (line 2550) at startQUnit (line 12) at onPageLoaded (line 16) (line 18) While Running:C:\Dev_Scratch\testRunner.html

Error: Error: Called start() while test already started running While Running:C:\Dev_Scratch\testRunner.html

File: C:\Dev_Scratch\testRunner.html 1 total, 0 failed, took 0.01 seconds

Tests complete: 1 === 1 total, 0 failed, took 2.52 seconds ===

最佳答案

构建定义中没有可以更改状态的内置选项。

带 ✓ 的黄色表示部分通过。

如果你想将构建的状态更改为绿色。作为解决方法,您可以使用批处理文件来运行测试。那么你只需要 Redirecting Error Messages from Command Prompt: STDERR/STDOUT .这将达到目的。

关于qunit - 作为 TFS 构建的一部分运行 html QUnit 测试会在测试上下文之外给出有关 start() 的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41857196/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com