fakeServer.respond(); not working... #1130

funyapu opened this Issue Aug 18, 2016 · 2 comments


None yet

3 participants

funyapu commented Aug 18, 2016 edited

Sorry, but currently have no time to create a sample project...
Will do it on weekend if needed.


What did you expect to happen?

  1. Switch a <Td /> to <Input type="text"/> by clicking.
  2. POST a data by keyPress Enter in the <Input>.
  3. Update redux reducer(data store) on response.
  4. Flash DOM and the <Input /> should change to <TD />.

What actually happens

  • Test result
Error: Expected 'INPUT' to be 'TD' (test.spec.js:3485 <- webpack:///~/expect/lib/assert.js?3e24:24:0)
  • Error Log
ERROR LOG: 'Unhandled promise rejection', TypeError{stack:~~~

How to reproduce

Will write later. Should be like below....

  1. Create a React page w/ <Table />.
  2. Write a function to switch the <TD /> to <Input type="text" /> by clicking.
  3. Write a function to post data by key press on enter in <Input />.
  4. Test case will be like berow:
  it('edit nickname', (done) => {

    fakeServer.respondWith('POST', '/post_url',
        {'Content-Type': 'application/json'},
          nickname: 'edited'

    let getNicknameNode = () => TestUtils.findRenderedDOMComponentWithClass(component, 'nickname');

    // Switch the td to input

    // Change the value and POST it.
    getNicknameNode().value = 'ts';
    TestUtils.Simulate.keyPress(getNicknameNode(), {key: "Enter", keyCode: 13, which: 13});

      () => {
fatso83 commented Aug 18, 2016

This is clearly not a sufficient test case to prove that anything is wrong with Sinon. Your test error could be from any number of reasons, including errors in your React component. If you want to demonstrate an actual error in Sinon, please rid your test case of React specifics as there is no way of knowing if this is Sinon's fault or something else from the test case.

What is interesting is that you say this does not happen with Sinon 1.17.4. If you can provide us with any complete, runnable code that fails in 1.17.5 but not in 1.17.4, please do.

droarty commented Sep 23, 2016

I had a similarly weird issue when updating to 1.17.5. Rolling back to 1.17.4 fixed it.

I couldn't pin point sinon as the issue though. My specs fail due to then never being called in $.ajax({..}).then(). Where I used the ajax success: callback I didn't have problems. My problem in isolating this is in that I am also migrating React from 15.2.1 to 15.3.1. If I only update one of these two packages and not the other I don't get the problem. If I update both, I get the problem. Sorry I don't have time to dig in deeper, but thought I would share. Btw, in case it is relevant, I use jQuery 3.x and the respondImediately flag.

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