2017-08-10 39 views
0

我正在測試一個ember 2.13應用程序。我想檢索頁面標題的值,但是從測試document.title這樣做,從測試套件頁面抓取標題。 我可能在這裏忽略了一個簡單的餘燼特徵。任何提示?從驗收測試中從AUT檢索document.title - Ember 2

+0

的qunit使用自己的index.html頁面,而當你使用'document.title'在它的標題將被檢索。除非您正在測試的功能內部動態修改標題,否則只會調用與qunit相關的index.html標題。 – Sumit

+0

這就是我注意到Sumit 33的原因,因此我正在尋找一種方法在測試中檢索AUT的文檔標題。 – j4v1

回答

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