Git Product home page Git Product logo

Comments (12)

Fishbowler avatar Fishbowler commented on June 8, 2024

I now understand the witchcraft.
See "Warning for Deep Clone" in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
There's a reference to headers being kept.

from icedfrisby.

Fishbowler avatar Fishbowler commented on June 8, 2024

I've made the simple change to fix this, but there are now failing unit tests. These test run create and addHeader without any get/post/other verb command, something I hadn't anticipated.

Need to work out how to deal with this. I'd definitely rather preserve this than impose a new requirement that _request is called before a bunch of other stuff can be.

So I've discovered why this issue sometimes doesn't exhibit, so maybe the next step is to work out how to make it permanent.

from icedfrisby.

Fishbowler avatar Fishbowler commented on June 8, 2024

It's https://github.com/IcedFrisby/IcedFrisby/blob/master/lib/icedfrisby.js#L466
When you've got params with headers, you break the reference that's made between outgoing.headers and current.request.headers

from icedfrisby.

Fishbowler avatar Fishbowler commented on June 8, 2024

We can make this consistently unmagical with Lodash merge or something, but doing that means we need to grab current.request again at toss() time, at which point we probably wanna stop grabbing it (or so much of it) at _request.

Alternative is to introduce some recursive copying of children that are objects. There's probably some lodash helper for that too.

Sigh. This was a trivial fix yesterday...

from icedfrisby.

paulmelnikow avatar paulmelnikow commented on June 8, 2024

Ah hmm…

Even after #101 #100 #105 there is a lot of indirection in the parameters. I prefer something way more direct than what we have. Maybe the best thing would be for me to take a stab at cleaning up the header-handling next?

Do you have a failing unit test?

from icedfrisby.

Fishbowler avatar Fishbowler commented on June 8, 2024

That's a cracking idea! I'll write the unit test now.

from icedfrisby.

paulmelnikow avatar paulmelnikow commented on June 8, 2024

Refactoring anything around the headers at this point involves dealing with the tanglements of globalSetup. Since we've decided to remove that, I'm going to go ahead and do that now. The shared state issue will be fixed along the way.

Will that fit into the changes you're making?

from icedfrisby.

Fishbowler avatar Fishbowler commented on June 8, 2024

I was only making changes to fix problems after I made changes to my local repo of tests to cope with the globalSetup problem, so they can all be binned.

Here's the failing test:

it('should send all headers when you bootstrap with params', function(){

    frisby.create(this.test.title)
      .baseUri('http://httpbin.org')
      .get('/headers',{headers:{'Abc':'def'}})
      .addHeader('Foo','bar')
      .expectContainsJSON('headers',{
        "Abc": "def"
      })
      .expectContainsJSON('headers',{
        "Foo": "bar"
      })
      .toss()
  })

In my context, the params going into the get/post are coming from a shared variable that was the request section of the globalSetup

from icedfrisby.

paulmelnikow avatar paulmelnikow commented on June 8, 2024

Ooh, interesting. Hmm, I bet that will be failing on my branch too.

I'm working through adding a .config() method to replace the settings that globalSetup() offered.

from icedfrisby.

paulmelnikow avatar paulmelnikow commented on June 8, 2024

I pushed a branch with some progress. Right now the config() method only works correctly if it's invoked before _request(). Fixing that is going to take some more untangling, so I think it's worth leaving there for now.

I opened #106. There's probably a bit of work left to do… feel free to test and/or push some commits. I'll pick it up again shortly!

from icedfrisby.

paulmelnikow avatar paulmelnikow commented on June 8, 2024

Looks like this is on track to be fixed in #106.

from icedfrisby.

Fishbowler avatar Fishbowler commented on June 8, 2024

This is fixed

from icedfrisby.

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.