测试 Ember 个组件时出错
Error while testing Ember Components
我想测试我的 ember 组件。我没有使用 ember-cli.I 遵循 ember 指南中给出的内容。但是 this.subject() 方法未定义。
另外,我收到以下错误
setUp failed on <test-case-name> : assert.async is not a function
Died on test #2 : this.render is not a function
TearDown Failed on <test-case-name> : assert.async is not a function
我没有使用过任何异步函数。在我的测试用例中,我单独写了一行 this.render()。
提前致谢,
库卡
默认情况下,在 Ember 2.0 中,您正在编写集成测试,而不是单元测试。并且出于某种原因,不允许您在集成测试中访问组件对象。
要使您的测试成为单元测试,请将 unit: true
添加到测试模块定义中:
moduleForComponent('pretty-color', {
unit: true,
// specify the other units that are required for this test
// needs: ['component:foo', 'helper:bar']
});
遗憾的是,该文档目前已过时并且不讨论组件集成测试。要了解有关集成测试的更多信息,请参阅 http://alisdair.mcdiarmid.org/ember-component-integration-tests/
我想测试我的 ember 组件。我没有使用 ember-cli.I 遵循 ember 指南中给出的内容。但是 this.subject() 方法未定义。 另外,我收到以下错误
setUp failed on <test-case-name> : assert.async is not a function
Died on test #2 : this.render is not a function
TearDown Failed on <test-case-name> : assert.async is not a function
我没有使用过任何异步函数。在我的测试用例中,我单独写了一行 this.render()。
提前致谢, 库卡
默认情况下,在 Ember 2.0 中,您正在编写集成测试,而不是单元测试。并且出于某种原因,不允许您在集成测试中访问组件对象。
要使您的测试成为单元测试,请将 unit: true
添加到测试模块定义中:
moduleForComponent('pretty-color', {
unit: true,
// specify the other units that are required for this test
// needs: ['component:foo', 'helper:bar']
});
遗憾的是,该文档目前已过时并且不讨论组件集成测试。要了解有关集成测试的更多信息,请参阅 http://alisdair.mcdiarmid.org/ember-component-integration-tests/