Skip to content

Feature/post with dynamic body#84

Open
HerrPfister wants to merge 7 commits intonamshi:masterfrom
HerrPfister:feature/POST-with-dynamic-body
Open

Feature/post with dynamic body#84
HerrPfister wants to merge 7 commits intonamshi:masterfrom
HerrPfister:feature/POST-with-dynamic-body

Conversation

@HerrPfister
Copy link

@HerrPfister HerrPfister commented Dec 6, 2019

Modified previously submitted PR #44 for responding to POST requests with different mocks based on the requests body. This should resolve #38. I haven't run in to issues on Windows.

I also updated some of the tests' mock folders to be a little more descriptive of what they were doing.

Lastly, I changed the file format for these mock files to be:
POST@[json file name without extension].mock

var data = fs.readFileSync(join(fullPath, file), { encoding: 'utf8' });

try {
if (jsonBody === JSON.stringify(JSON.parse(data))) {
Copy link

Choose a reason for hiding this comment

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

I think you could change this check to if (JSON.stringify(JSON.parse(jsonBody)) === JSON.stringify(JSON.parse(data))) { to avoid a falsy result due to an extra white space or some other formatting detail.

Copy link

Choose a reason for hiding this comment

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

I agree with that because without it, it couldn't work correctly (if some space character exist for example)

@gigaga
Copy link

gigaga commented Dec 9, 2020

Hello.

Any news for this PR? It will be great if we can use it under Windows 👍

Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON payloads

4 participants