如何使用不同的数据库进行量角器e2e测试?

时间:2016-08-23 16:53:14

标签: angularjs node.js mongodb protractor e2e-testing

我想仅为我的e2e测试使用数据库,而不使用我的开发数据库。 我需要测试登录,此时测试是使用我的开发数据库,​​而不是我需要的,我需要在数据库中创建一个用户,然后测试登录重定向到仪表板并显示用户信息 我正在使用节点,角度,量角器和mongo。 感谢

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 = 'john@doe.com';
      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']
};

1 个答案:

答案 0 :(得分:2)

量角器没有您的应用程序使用的数据库。它将在提供的URL的帮助下开始测试应用程序。如果要在不同的环境中测试应用程序,则需要创建现有应用程序的副本,指向不同的测试数据库,并在量角器测试中使用应用程序URL的复制版本。