Skip to content

Commit

Permalink
Removed assert about changing Pretender config. Ensured trackRequests…
Browse files Browse the repository at this point in the history
… was set properly
  • Loading branch information
cah-brian-gantzler committed Jun 1, 2022
1 parent c15a147 commit 36528ba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
13 changes: 3 additions & 10 deletions lib/mock-server/pretender-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default class PretenderConfig {

create(mirageServer, config) {
this.mirageServer = mirageServer;
this.pretender = this._create(mirageServer);
this.pretender = this._create(mirageServer, config);

/**
Mirage uses [pretender.js](https://github.com/trek/pretender) as its xhttp interceptor. In your Mirage config, `this.pretender` refers to the actual Pretender instance, so any config options that work there will work here as well.
Expand Down Expand Up @@ -128,13 +128,6 @@ export default class PretenderConfig {
this._configureDefaultPassthroughs();
}

let didOverridePretenderConfig =
config.trackRequests !== undefined && this.pretender;
assert(
!didOverridePretenderConfig,
"You cannot modify Pretender's request tracking once the server is created"
);

/**
Set the number of milliseconds for the the Server's response time.
Expand Down Expand Up @@ -233,7 +226,7 @@ export default class PretenderConfig {
* @return {Object} A new Pretender instance.
* @public
*/
_create(mirageServer) {
_create(mirageServer, config) {
if (typeof window !== "undefined") {
return new Pretender(
function () {
Expand Down Expand Up @@ -316,7 +309,7 @@ export default class PretenderConfig {
);
};
},
{ trackRequests: mirageServer.shouldTrackRequests() }
{ trackRequests: config.trackRequests || false }
);
}
}
Expand Down
12 changes: 0 additions & 12 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,18 +386,6 @@ export default class Server {
return typeof this.logging !== "undefined" ? this.logging : !this.isTest();
}

/**
* Determines if the server should track requests.
*
* @method shouldTrackRequests
* @return The value of this.trackRequests if defined, false otherwise.
* @public
* @hide
*/
shouldTrackRequests() {
return Boolean(this.trackRequests);
}

/**
* Load the configuration given, setting timing to 0 if in the test
* environment.
Expand Down

0 comments on commit 36528ba

Please sign in to comment.