【发布时间】:2015-08-25 02:03:43
【问题描述】:
我正在尝试通过关注this tutorial 来构建一个 hello world Ember.js 应用程序...我已经到了测试“关于”页面链接的部分。
我的设置是:
QUnit 1.18.0; Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36
Ember version: 1.13.8
node: 0.12.7
npm: 2.13.4
os: darwin x64
我的router.js 是:
import Ember from 'ember';
import config from './config/environment';
var Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.route('about');
});
export default Router;
我的application.hbs 是:
<h2 id="title">Welcome to Boston Ember</h2>
{{link-to 'About' 'about'}}
{{outlet}}
我的about.hbs 是:
<h3>About</h3>
<p>Boston Ember is the monthly meetup where awesome people get together
做很棒的 Ember 相关的事情!
我的about-page-test.js 是:
import Ember from 'ember';
import startApp from 'bostonember/tests/helpers/start-app';
var App;
module('Integration - About Page', {
beforeEach: function() {
App = startApp();
},
afterEach: function() {
Ember.run(App, 'destroy');
}
});
test('Should navigate to the About page', function() {
visit('/').then(function(assert) {
click("a:contains('About')").then(function(assert) {
assert.equal(find('h3').text(), 'About');
});
});
});
页面正常运行,命令行不返回任何错误:
file changed templates/application.hbs
Build successful - 691ms.
但是当我转到http://localhost:4200/tests 时,我看到一堆错误...
Integration - About Page: Should navigate to the About page (1, 0, 1)Rerun210 ms
TypeError: Cannot read property 'equal' of undefined@ 190 ms
Expected: true
Result: false
Diff: trufalse
Source:
at http://localhost:4200/assets/test-support.js:4578:13
at exports.default._emberTestingAdaptersAdapter.default.extend.exception (http://localhost:4200/assets/vendor.js:52460:34)
at onerrorDefault (http://localhost:4200/assets/vendor.js:43162:24)
at Object.exports.default.trigger (http://localhost:4200/assets/vendor.js:67346:11)
at Promise._onerror (http://localhost:4200/assets/vendor.js:68312:22)
at publishRejection (http://localhost:4200/assets/vendor.js:66619:15)
JSHint - integration: integration/about-page-test.js should pass jshint (1, 0, 1)Rerun1 ms
integration/about-page-test.js should pass jshint.
integration/about-page-test.js: line 6, col 1, 'module' is not defined.
integration/about-page-test.js: line 15, col 1, 'test' is not defined.
integration/about-page-test.js: line 16, col 28, 'assert' is defined but never used.
3 errors@ 0 ms
Expected: true
Result: false
Diff: trufalse
Source:
at Object.<anonymous> (http://localhost:4200/assets/bostonember.js:337:12)
at Object.Test.run (http://localhost:4200/assets/test-support.js:3566:28)
at http://localhost:4200/assets/test-support.js:3695:11
at process (http://localhost:4200/assets/test-support.js:3254:24)
at begin (http://localhost:4200/assets/test-support.js:3299:2)
at http://localhost:4200/assets/test-support.js:3315:4
我尝试过使用this.route('about'); 的一些不同变体,尽管我认为这很好,因为该功能有效。我也在测试中尝试了一些不同的东西,但没有任何东西可以摆脱浏览器错误。
【问题讨论】:
标签: javascript ruby-on-rails node.js ember.js