Skip to content

Commit

Permalink
Warn, don't raise, a double started Pretender
Browse files Browse the repository at this point in the history
  • Loading branch information
Trek Glowacki committed Oct 18, 2016
1 parent cc496ae commit 2961ebc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 22 deletions.
3 changes: 3 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"define",
"process"
],
"globals": {
"console":false
},
"expr": true,
"proto": true,
"strict": true,
Expand Down
5 changes: 3 additions & 2 deletions pretender.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,9 @@ function interceptor(pretender, nativeRequest) {
FakeRequest.prototype = proto;

if (nativeRequest.prototype._passthroughCheck) {
throw new Error('You created a second Pretender instance while there was already one running. ' +
'Running two Pretender servers at once will lead to unexpected results!' +
console.warn('You created a second Pretender instance while there was already one running. ' +
'Running two Pretender servers at once will lead to unexpected results and will ' +
'be removed entirely in a future major version.' +
'Please call .shutdown() on your instances when you no longer need them to respond.');
}
return FakeRequest;
Expand Down
20 changes: 0 additions & 20 deletions test/creation_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,6 @@ var pretender;
var describe = QUnit.module;
var it = QUnit.test;

describe('pretender creation - without shutdown', function(config) {
var secondPretender;

config.beforeEach(function() {
pretender = new Pretender();
});

config.afterEach(function() {
pretender.shutdown();
});

test('an error is thrown when you start a new pretender while another one is running', function(assert) {
var message = 'You created a second Pretender instance while there ' +
'already one running. Running two Pretender servers at once will lead to unexpected results!';
assert.throws(function() {
new Pretender();
}, message);
});
});

describe('pretender creation', function(config) {
config.afterEach(function() {
if (pretender) {
Expand Down

0 comments on commit 2961ebc

Please sign in to comment.