【问题标题】:can't import the test helper addon in ember-cli-mirage无法在 ember-cli-mirage 中导入测试助手插件
【发布时间】:2020-06-26 13:58:35
【问题描述】:

面临同样的问题 - https://github.com/miragejs/ember-cli-mirage/issues/1445

未捕获的错误:找不到从 project-name/mirage/factories/addon 导入的模块 project-name/tests/helpers/push-mirage-into-store

最初遇到此错误并尝试了 @makepanic 说明

之后

未捕获的错误:找不到从 project-name/mirage/helpers/push-mirage-into-store 导入的模块 @ember/test-helpers

请您帮忙解决这个问题。

【问题讨论】:

  • 你能提供更多的上下文吗? push-mirage-into-store.js 是什么样的?您在运行测试或在开发中运行时是否遇到此问题?

标签: ember.js ember-cli ember-cli-mirage ember-cli-addons


【解决方案1】:

我打赌你遇到了错误,描述为in this comment by makepanic in the GitHub issue you linked

直接运行应用程序时,浏览器会打开 index.html 没有加载tests.js。该文件包含与 测试。

如果你打开 tests/index.html,它也会加载 tests.js 并添加任何 tests/* 下的模块到加载器注册表。

这意味着如果没有加载测试文件,您将无法导入任何内容 来自测试/*。

如果您在运行ember serve 时遇到该问题,您会受到该问题的影响。

评论还包括一个可能的解决方案:

随着您将助手移动到 /mirage,它们会在 index.html 和 tests/index.html 中注册。

另一种方法是在所有环境中禁用 mirage,test 除外。但是,如果您将 mirage 仅用于测试而不用于开发,那么这只是一个可行的解决方案。

【讨论】:

    猜你喜欢
    • 2014-11-03
    • 2015-10-25
    • 2015-06-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多