【问题标题】:Ember-qunit unit test helpers: how do they work now?Ember-qunit 单元测试助手:它们现在如何工作?
【发布时间】:2023-03-16 15:48:01
【问题描述】:

直到最近我才包含文件...

https://raw.githubusercontent.com/rwjblue/ember-qunit-builds/master/dist/globals/main.js

...在“TestRunner”页面中,我将打开该页面以运行我的所有 Ember 单元测试。一切都很棒。

几天前,那个文件从 github 上消失了,所以我开始寻找让我的单元测试(例如 moduleForComponent 测试)运行的新方法。

我首先尝试从 ember-qunit-builds 存储库中简单地包含 ember-qunit.js 文件,但类似 ​​could not find module 'ember' 之类的错误又回来了。

我是否正确地说 ember-qunit 以某种方式依赖于ember-test-helpers?对于在测试代码之前应该包含哪些引用,我有点迷茫……我感觉我缺少一些与 ES6 样式模块(导出/导入等)相关的东西,而我对此几乎没有经验。

有人可以在这里指出我正确的方向吗?我应该在我的 'TestRunner.html' 页面上包含什么来让 'moduleForComponent' 风格的测试再次发生?

注意:我处于 .NET 环境中,我知道经常提到的用于“安装”这些东西的工具(如 Bower/npm)并不真正可用(这些是必需品吗?让它工作?)。

【问题讨论】:

    标签: unit-testing ember.js ecmascript-6 ember-qunit


    【解决方案1】:

    我不太确定您的问题出在哪里,但我可以将我的index.html 的相关部分粘贴给您(我在这里使用的是 Ember App Kit):

    <!-- @if tests=true -->
    <script src="/vendor/ember-shim.js"></script>
    <link rel="stylesheet" href="/vendor/qunit/qunit/qunit.css">
    <script src="/vendor/qunit/qunit/qunit.js"></script>
    <script src="/vendor/qunit-shim.js"></script>
    <script src="/vendor/ember-qunit/dist/named-amd/main.js"></script>
    <div id="qunit"></div>
    <!-- @endif -->
    

    <!-- @if tests=true -->
    <div id="qunit-fixture"></div>
    <script src="/tests/tests.js"></script>
    <script src="/tests/test-helper.js"></script>
    <script src="/tests/test-loader.js"></script>
    <script src="/testem.js"></script>
    <!-- @endif -->
    

    如果您特别在寻找 dist/globals/main.js 文件,那么您可以随时访问 github 并选择较旧的 tag(不是主文件),然后转到文件的原始版本。这是 0.1.8 版本的链接:

    https://raw.githubusercontent.com/rwjblue/ember-qunit/v0.1.8/dist/globals/main.js

    如果您想保持最新状态,请使用此存储库: https://github.com/rwjblue/ember-qunit-builds 这有什么帮助吗?

    【讨论】:

    • 非常感谢您的建议/意见。我的 html 页面的结构看起来基本相同。关键似乎是这个文件:“/vendor/ember-qunit/dist/named-amd/main.js”。我现在在网上哪里可以找到它?几天前,它已从 ember-qunit-builds 存储库中删除,我不知道如何再次获取它:(...
    • 太好了,谢谢。现在应该可以解决我的问题,所以我接受了您的回答。我想我只是担心如果我想与 ember-qunit 保持“最新”状态,我会遇到类似的问题。如果我理解正确,他们将不会提供这样的“main.js”。你知道接下来的流程是什么吗?我们是否希望以某种方式“构建”它?
    • 嘿,如果你只是去github.com/rwjblue/ember-qunit,那么它的第一段说:“重要说明 - 该项目的构建过程目前正在改变。在 v0.1.8 及以下版本中,构建被推送到 dist/ 目录。接下来,我们会将构建推送到单独的 repo:ember-qunit-builds。在此转换完成之前,如果它引用 rwjblue/ember-qunit#master,请更新您的 bower.json。而是指定版本 (rwjblue/ember-qunit#v0.1.8) 或 SHA(f3f852789bc80486afae1a9ddb7810356050fe9b 或更早版本)。”
    • 这样你就可以从github.com/rwjblue/ember-qunit-builds拉取最新的了
    • 哦,对不起...也许你只需要拉普通的 ember-qunit.js 文件?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-03
    • 1970-01-01
    • 1970-01-01
    • 2014-10-22
    • 2023-04-03
    • 1970-01-01
    相关资源
    最近更新 更多