Hooking up protractor E2E tests with node-replay

I've been messing around with node-replay (https://github.com/assaf/node-replay) to see if there is a way I can hook it up with my protractor tests to get my tests to run with recorded data (so they run quicker and not so damn slow).

I installed node-replay as instructed on the github page. Then in my test file I include some node replay code as follow

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();

});

and my config file looks like this:

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
  }
};

Then I try to rub my tests with grunt by saying

REPLAY=record grunt protractor

But I get tons of failures. Grunt protractor was running all of tests fine and with no failures before I added node-replay so maybe my logic is flawed in how to connect these two together. Any suggestions as to what I'm missing

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

Problem is that http requests to 127.0.0.1:9000 are done by the Browser, not within your NodeJS Protractor code, so replay won't work in this infrastructure scenario.

There is ongoing discussion on Protractor Tests without a Backend here and some folks relies on mocking the backend client side with Protractor's addMockModule in a similar way they already do for Karma unit tests.

Personally I don't agree with mocking for e2e since the whole point of end-to-end was to test the whole real app.

HTTP replay may not be such a bad idea to get things go faster.

Ideally what i hoped to find was a tool that works like this:

  1. Run a proxy capture http server the first time for later replay:

    capture 127.0.0.1:9000 --into-port 3333

  2. Run your e2e tests against a baseUrl = '127.0.0.1:3333';. All requests/responses will be cached/saved.

  3. Serve the cached content from now on:

    replay --at-port 3333

  4. Run your e2e tests again still on baseUrl por 3333. This time it should run faster since it's serving cached content.

Couldn't find it, let me know if you have better luck!