Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with upgrade from 1.5.1 -> 1.5.2 #97

Closed
krnjn opened this issue Jan 27, 2017 · 5 comments
Closed

Issue with upgrade from 1.5.1 -> 1.5.2 #97

krnjn opened this issue Jan 27, 2017 · 5 comments

Comments

@krnjn
Copy link

krnjn commented Jan 27, 2017

I'm having an issue with a test that works fine on versions 1.5.1 and below that does not seem to work on 1.5.2 (using Jest + Enzyme). Following the README, this should work just fine, but seems to be having issues. Here's a sample of the code for reference:

import React from 'react';
import {shallow, mount} from 'enzyme';
import lolex from 'lolex';

import ResponsesSearch from 'js/responses/components/search/index';

  it('calls #applySearchTerm on submit', () => {
    const clock = lolex.install();
    const searchTermFn = jest.fn();
    const wrapper = mount(
      <ResponsesSearch applySearchTerm={searchTermFn} />
    );
    const input = wrapper.find('input');

    input.node.value = 'blah';
    input.simulate('change'); // we have an onChange callback on this input after 500ms

    clock.tick(500);

    expect(searchTermFn).toHaveBeenCalledWith('blah');

    clock.uninstall();
  });

I can provide more code if needed, but I'm wondering if I'm doing something wrong here with the implementation of lolex with:

const clock = lolex.install();
clock.tick(500);
clock.uninstall();

Any help would be appreciated!

@fatso83
Copy link
Contributor

fatso83 commented Jan 30, 2017

As can be seen from the changelog this might be related to #87 which was supposed to fix compatibility with React Native.

It might be that this is not an actual error/regression in Lolex, but rather exposes some fundamental design flaw in the code you are testing. But if fully might be a problem with lolex too ... See the changes in #87 and see if you can spot something that might be relevant.

@krnjn
Copy link
Author

krnjn commented Jan 30, 2017

@fatso83 thanks for the reply. I'm not sure how the changes in that commit would be causing the issue. For reference, here's the test failure / stack trace provided:

 FAIL  spec/js/responses/components/search/index_spec.js.jsx
  ● responses/components/search/index › calls #applySearchTerm on submit

    expect(jest.fn()).toHaveBeenCalledWith(expected)
    
    Expected mock function to have been called with:
      ["blah"]
    But it was not called.
      
      at Object.<anonymous> (spec/js/responses/components/search/index_spec.js.jsx:36:26)
      at handle (node_modules/worker-farm/lib/child/index.js:41:8)
      at process.<anonymous> (node_modules/worker-farm/lib/child/index.js:47:3)
      at emitTwo (events.js:106:13)
      at process.emit (events.js:191:7)
      at process.nextTick (internal/child_process.js:752:12)
      at _combinedTickCallback (internal/process/next_tick.js:67:7)
      at process._tickCallback (internal/process/next_tick.js:98:9)

I'll continue looking at it on my end, but let me know if you find anything further / need additional information!

@cjohansen
Copy link
Contributor

@krnjn Did you figure out what happened?

@krnjn
Copy link
Author

krnjn commented Feb 25, 2017

@cjohansen nope, just locked down lolex@1.5.1

@fatso83
Copy link
Contributor

fatso83 commented Jul 13, 2017

This has stalled and we have no test case to test against. Closing until someone can show this as an error in lolex

@fatso83 fatso83 closed this as completed Jul 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants