我想測試嚴重依賴API的Angular應用程序。該API正在與phpunit單獨測試,我們正在創建燈具,所以我希望不必在Angular中創建另一套模擬燈具。我現在只使用了鉻合金驅動器的量角器。AngularJS e2e使用量角器和遠程API測試
首先,我必須通過不是Angular應用程序的頁面登錄。
然後我去一個網頁,顯示了ng-if='loadingCards'
裝載機和隱藏的表ng-if='!loadingCards'
,然後在API調用來檢索卡完成後,中loadingCards
值翻轉。
下面是測試規範的開始,它會讓您通過非角度登錄,然後將您帶到卡片列表頁面。我想要做的就是看cards
$ scope變量的內容,看看API確實返回了一些東西,但我總是得到一個空數組。
describe('User cards page', function() {
var driver;
var ptor;
beforeEach(function() {
ptor = protractor.getInstance();
ptor.ignoreSynchronization = true;
browser.ignoreSynchronization = true;
driver = ptor.driver;
});
it('should login', function() {
driver.get('http://local.local.com/login');
driver.findElement(protractor.By.name('_username')).sendKeys('admin');
driver.findElement(protractor.By.name('_password')).sendKeys('admin');
driver.findElement(protractor.By.css('input[type="submit"]')).click();
});
it('should list cards', function() {
browser.get('http://local.local.com/cms/cards');
var ucards = element.all(by.repeater('card in cards')).then(function(cards) {
console.log(cards);
});
//expect(ucards.count()).toEqual(3);
});
});
什麼給手動,視覺檢查? – bdavidxyz
@ davidb583我不明白你的意見。 –