sepia icon indicating copy to clipboard operation
sepia copied to clipboard

Possibility to disable sepia for certain tests

Open satazor opened this issue 8 years ago • 4 comments

I'm developing a complex set of test suites and I want to disable sepia for some of them. Besides the filter feature, is there any way to accomplish this, e.g.: sepia.disable()/enable()?

Thanks

satazor avatar Apr 11 '16 22:04 satazor

After analyzing sepia, it seems there's no such feature. Would you guys be interested in adding it?

satazor avatar Apr 12 '16 10:04 satazor

I've made a workaround:

// tests/util/sepia.js

'use strict';

const http = require('http');
const https = require('https');

const originalRequests = { http: http.request, https: https.request };
const sepia = require('sepia');
const sepiaRequests = { http: http.request, https: https.request };

/**
 * Turns sepia on.
 */
function enable() {
    http.request = sepiaRequests.http;
    https.request = sepiaRequests.https;
}

/**
 * Turns sepia off.
 */
function disable() {
    http.request = originalRequests.http;
    https.request = originalRequests.https;
}

disable();

sepia.enable = enable;
sepia.disable = disable;

module.exports = sepia;

satazor avatar May 11 '16 09:05 satazor

Thanks, I needed this as it seems to break supertest requests to my app. I'm not sure if anyone else experienced that and has a better workaround?

paulwalker avatar Aug 05 '16 03:08 paulwalker

I had the same issue. This would be a great addition.

aneilbaboo avatar Dec 20 '16 14:12 aneilbaboo