我正在按照本教程尝试构建一个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');
尽管我认为这很好,因为该功能有效。我还在测试中尝试了一些不同的方法,但没有摆脱浏览器错误的方法。
好像我将assert
s放在错误的位置。通过了以下内容:
import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from '../helpers/start-app';
var App;
module('Integration - About Page', {
beforeEach: function() {
App = startApp();
},
afterEach: function() {
Ember.run(App, 'destroy');
}
});
test('Should click About link', function(assert) {
visit('/').then(function() {
click("a:contains('About')").then(function() {
assert.equal(find('h3').text(), 'About');
});
});
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句