Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions addon-test-support/mock-provider/mirage.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ export default class MirageProvider extends MockProvider {
let { startMirage } = require(`${modulePrefix}/initializers/ember-cli-mirage`);
this.server = startMirage();
this.server.passthrough('/_pact/*path');

// Workaround for issue: https://github.com/salsify/ember-cli-pact/issues/32
const originalHandler = this.server.pretender.handledRequest;
this.server.pretender.handledRequest = (verb, path, request) => {
if (!this.interaction.captured) this.recordRequest(request);
return originalHandler(verb, path, request);
};
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

@gustavocabral gustavocabral Jan 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} catch (error) {
throw new Error(`Unable to start mirage server; is ember-cli-mirage installed? ${error.message}`);
}
Expand All @@ -69,6 +76,7 @@ let mode = 'data';

export function PactEnabled(SerializerClass) {
return class PactEnabledSerializer extends SerializerClass {
// serialize will NOT be invoked if response's body is NOT serializable (e.g. empty body after DELETE request)
serialize(resource, request) {
let serialized = super.serialize(...arguments);
if (activeProvider) {
Expand Down