I’d look into injecting the configuration data. Maybe something like this:
// production code
function worker(configData) {
var result = {};
// populate result taking into account configData
return result;
}
// test code
describe('worker', function() {
var result;
var configData = {...};
context('when host is local host', function() {
beforeEach(function() {
configData.host = 'localhost';
result = worker(configData);
});
it('it does something special', function() {
expect(result).to.contain(theSpecialBit);
});
});
});