首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从验收测试中检索document.title - Ember 2

从验收测试中检索document.title - Ember 2
EN

Stack Overflow用户
提问于 2017-08-10 22:56:05
回答 1查看 85关注 0票数 0

我正在测试一个ember 2.13应用程序。我想检索页面标题的值,但这样做是因为测试中的document.title从测试套件页面中获取了标题。这里我可能忽略了一个简单的ember-qunit特性。有什么提示吗?

EN

回答 1

Stack Overflow用户

发布于 2017-08-17 11:56:07

这可能有点过头了,但您可以使用http://tim-evans.github.io/ember-page-title/。并像他们一样测试它:

代码语言:javascript
复制
// 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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45617146

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档