我正在测试一个ember 2.13 app。我想检索页面标题的值,但是从测试中document.title
执行此操作会从测试套件页面获取标题。
我可能会在这里忽略一个简单的ember-qunit功能。任何提示?
答案 0 :(得分:0)
可能有点矫枉过正,但您可以使用http://tim-evans.github.io/ember-page-title/。并像他们一样测试它:
// Testem appends progress to the title...
// and there's no way to stop this at the moment
function title() {
return findWithAssert('title', 'head').text().trim().replace(/^\(\d+\/\d+\)/, '');
}
test('the default configuration works', async function (assert) {
assert.expect(1);
await visit('/posts');
assert.equal(title(), 'My App | Posts');
});
https://github.com/tim-evans/ember-page-title/blob/master/tests/acceptance/posts-test.js#L17-L28