2016-08-23 75 views
-2

我想只爲我的e2e測試使用數據庫,並且不使用我的開發數據庫。 我需要測試登錄,在這一刻測試使用我的開發數據庫,​​並不是我所需要的,我需要在數據庫中創建一個用戶,然後測試登錄重定向到儀表板並顯示用戶信息 我正在使用節點,角度,量角器和mongo。 感謝如何爲量角器e2e測試使用不同的數據庫?

login.test.js

describe('login redirects to dashboard and displays user email', function(){ 
    it('should redirect to dashboard and display user email', function() { 

     var email = '[email protected]'; 
     browser.get('http://localhost:3000/#/login'); 

     element(by.id('username')).sendKeys(email); 
     element(by.id('password')).sendKeys('none123'); 
     element(by.id('submit-form')).click(); 

     expect(browser.getCurrentUrl()).toBe('http://localhost:3000/#/dashboard'); 
     expect(element(by.css('.username')).getText()).toEqual('Hi, ' + email); 
    }); 
}); 

conf.js

exports.config = { 
    seleniumAddress: 'http://localhost:4444/wd/hub', 
    specs: ['*.test.js'] 
}; 

回答

2

量角器犯規的數據庫應用程序是using.It會剛開始與提供URL的幫助下測試應用程序。如果你想在不同的環境下測試你的應用程序,那麼你需要創建一個現有應用程序的副本將指向一個不同的測試數據庫,並在量角器測試中使用應用程序url的複製版本。