Skip to content
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.

Allow regex in passThrough #124

Open
delijati opened this issue Jan 5, 2017 · 0 comments
Open

Allow regex in passThrough #124

delijati opened this issue Jan 5, 2017 · 0 comments

Comments

@delijati
Copy link

delijati commented Jan 5, 2017

I would like to record a 'request' call in my app which is a 'localhost' service:

app.js:

'use strict';

const express = require('express');
const request = require('superagent');

var app = express();

app.get('/hammer/version', function(req, res) {
    request
        .get('http://localhost:7777/geturl')
        .end(function(err, response) {
            console.log(response.body);
            res.status(200).json({
                version: '0.1.0',
                url: response.body.url
            });
        });
});

module.exports = app;

test.js:

/* global describe, it */
'use strict';

const request = require('supertest');
const app = require('./app.js');

var path = require('path');
const Replay = require('replay');

Replay.fixtures = __dirname + '/fixtures/replay';
// -> All localhost request are ignored :/ RegEx would work
Replay.passThrough('/hammer/*');

describe('Version test', function() {
    this.timeout(0);

    it('test version', function(done) {
        request(app)
            .get('/hammer/version')
            .expect(200, {
                url: "http://www.foobar.org",
                version: '0.1.0'
            })
            .end(function(err, res) {
                if (err) return done(err);
                done();
            });
    });
});
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant