testing - 来自流星测试的乱码测试结果输出:mocha
问题描述
Meteor 1.7 的推荐测试框架似乎是meteortesting:mocha
.
使用 Meteor 1.7.0.3,我创建了一个默认应用程序 ( meteor create my-app
),它具有以下测试 (in test/main.js
)
import assert from "assert";
describe("my-app", function () {
it("package.json has correct name", async function () {
const { name } = await import("../package.json");
assert.strictEqual(name, "noteit");
});
if (Meteor.isClient) {
it("client is not server", function () {
assert.strictEqual(Meteor.isServer, false);
});
}
if (Meteor.isServer) {
it("server is not client", function () {
assert.strictEqual(Meteor.isClient, false);
});
}
});
我跑了
meteor add meteortesting:mocha
meteor test --driver-package meteortesting:mocha
并使用meteortesting:mocha
@2.4.5_6 我在控制台中得到了这个:
I20180728-12:06:37.729(2)? --------------------------------
I20180728-12:06:37.729(2)? ----- RUNNING SERVER TESTS -----
I20180728-12:06:37.729(2)? --------------------------------
I20180728-12:06:37.729(2)?
I20180728-12:06:37.730(2)?
I20180728-12:06:37.731(2)?
I20180728-12:06:37.737(2)? the server
✓ fails a test.753(2)?
I20180728-12:06:37.755(2)?
I20180728-12:06:37.756(2)?
I20180728-12:06:37.756(2)? 1 passing (26ms)
I20180728-12:06:37.756(2)?
I20180728-12:06:37.757(2)? Load the app in a browser to run client tests, or set the TEST_BROWSER_DRIVER environment variable. See https://github.com/meteortesting/meteor-mocha/blob/master/README.md#run-app-tests
=> Exited with code: 0
=> Your application is crashing. Waiting for file change.
实际上,它重复了三遍。不漂亮。而且我没想到通过测试会使我的应用程序崩溃。
同样在浏览器中我得到了这个
根据Meteor 测试指南,我期待的输出更像是漂亮的输出:
解决方案
与大多数 Node.js 一样,几乎任何东西都有许多分支。所以也与meteortesting:mocha
.
cultofcoders:mocha
似乎有一些提交,这曾经是 Meteor 推荐的practicalmeteor:mocha
测试框架。
如果你跑
meteor add cultofcoders:mocha
meteor test --driver-package cultofcoders:mocha
你会得到很好的输出。
出于好奇,我发现cultofcoders:mocha
我得到的 ( meteor list | grep mocha
) 版本是 2.4.6,这是 github repo 没有的版本...
推荐阅读
- raku - 使用 Metamodel::ConcreteRoleHOW.new_type 时出错
- google-cloud-dataflow - Beam 管道在 GroupByKey 与窗口后不产生任何输出,我得到内存错误
- neo4j - NEO4J Cypher 查找具有多个关系计数的节点
- matlab - Why is a variable undefined when trying to analyse .bat file in MATLAB?
- android - 如何在 iOS 和 Android 的给定时间检测用户是否仅在一台设备上处于活动状态
- json - Installing gem json 2.2.0 failed - windows
- elasticsearch - How to remove multiple fields from index?
- sql - Postgresql:从 EXECUTE 输出导出到 csv 数据
- xcode - Xcode 10.2, iOS 12.2 : Application installed over OTA(Enterprise) not opening
- django - 使用 Django 在谷歌应用引擎中部署时,PyYAML 有多重要?