通过节点重放连接量angular器E2Etesting

我一直在节点重播( https://github.com/assaf/node-replay ),看看是否有一种方法,我可以把它与我的量angular器testing,让我的testing与logging的数据运行(所以他们跑得更快,而不是那么该死)。

我按照github页面的指示安装了节点重播。 然后在我的testing文件中包含一些节点重播代码,如下所示

describe('E2E: Checking Initial Content', function(){ 'use strict'; var ptor; var Replay = require('replay'); Replay.localhost('127.0.0.1:9000/'); // keep track of the protractor instance beforeEach(function(){ browser.get('http://127.0.0.1:9000/'); ptor = protractor.getInstance(); }); 

和我的configuration文件看起来像这样:

 exports.config = { seleniumAddress: 'http://0.0.0.0:4444/wd/hub', // Capabilities to be passed to the webdriver instance. capabilities: { 'browserName': 'chrome' }, // Spec patterns are relatie to the current working directly when // protractor is called. specs: ['test/e2e/**/*.spec.js'], // Options to be passed to Jasmine-node. jasmineNodeOpts: { showColors: true, defaultTimeoutInterval: 300000 } }; 

然后,我试着用咕噜咕噜咕噜的testing来说

 REPLAY=record grunt protractor 

但是我得到了很多失败。 Grunt量angular器运行所有的testing罚款,并没有失败之前,我添加节点重播,所以也许我的逻辑是有缺陷的如何将这两个连接在一起。 任何build议,以什么我失踪

  1) E2E: Sample test 1 Message: UnknownError: Stacktrace: UnknownError: at <anonymous> 

问题是127.0.0.1:9000 http请求是由浏览器完成的,而不是在你的NodeJS量angular器代码中完成的,所以在这个基础设施情况下,重播将不起作用。

目前正在讨论没有后端的量angular器testing ,有些人依靠用量angular器的addMockModule来嘲笑后端客户端,就像他们已经为Karmaunit testing一样。

我个人不同意嘲笑e2e,因为整个端到端testing整个真实的应用程序。

HTTP重放可能不是一个坏主意 ,让事情变得更快。

理想情况下,我希望find的工具是这样工作的:

  1. 第一次运行代理服务器捕获http服务器以便以后重播:

    捕获127.0.0.1:9000 – 进入端口3333

  2. 针对baseUrl = '127.0.0.1:3333'; : baseUrl = '127.0.0.1:3333';运行e2etestingbaseUrl = '127.0.0.1:3333'; 。 所有请求/响应将被caching/保存。

  3. 从现在开始caching内容:

    重放 – 在端口3333

  4. 在baseUrl 3333上再次运行你的e2etesting。这次它应该运行得更快,因为它提供了caching的内容。

找不到它,让我知道如果你有更好的运气!