Giter VIP home page Giter VIP logo

Comments (10)

andrerod avatar andrerod commented on July 21, 2024

The exact problem is here:

if (typeof spec == 'string') {
return body.toString() === spec;
}

doing a toString on a JSON object (obtained in json = JSON.parse(body);), returns [object] which is not the same as a string with json in it.

from nock.

pgte avatar pgte commented on July 21, 2024

Landed in v0.17.1

from nock.

andrerod avatar andrerod commented on July 21, 2024

Not yet :(

Assume both input parameters are strings containing json.

This line will assign json to body:
if (json !== undefined) body = json;

There's no equivalent to the spec.

This line fails:
deepEqual(spec, body);

Because one is, a string:
{"intervalPeriod":2,"intervalUnit":"hour","startTime":"2013-04-02T18:46:54.897Z","status":"enabled"}

and the other is, an object:
{ intervalPeriod: 2,
intervalUnit: 'hour',
startTime: '2013-04-02T18:46:54.897Z',
status: 'enabled' }

from nock.

andrerod avatar andrerod commented on July 21, 2024

I think this logic should only happen if: if (
(typeof spec == 'object') &&

Then you know you need to try to convert the body to an object from a string.

from nock.

pgte avatar pgte commented on July 21, 2024

OK, gonna make a test for this.

from nock.

andrerod avatar andrerod commented on July 21, 2024
if (typeof spec == 'object') {

var json;
try { json = JSON.parse(body);} catch(err) {}

etc ...
}

from nock.

andrerod avatar andrerod commented on July 21, 2024

LMK if you need help, i may try to work on a PR for it later today

from nock.

pgte avatar pgte commented on July 21, 2024

Landed in v0.17.2.

from nock.

andrerod avatar andrerod commented on July 21, 2024

Seems to be fixed now. I'm now seeing a different issue but need to investigate the root cause before. Might be something on my side. Thanks!

from nock.

lock avatar lock commented on July 21, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue and add a reference to this one if it’s related. Thank you!

from nock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.