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

Tests for resizing window fails for Node.js v7 while working fine for v4-v6 #10660

Closed
Labels
question Issues that look for answers.

Comments

@yury-dymov
Copy link

yury-dymov commented Jan 6, 2017

Version: v7.4.0
Platform: Linux filo 4.8.0-30-generic #32-Ubuntu SMP Fri Dec 2 03:43:27 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

For my react-autocomplete-input package some tests are failing now. For node.js versions 4+ everything works fine as you can see. I updated all packages to the latest versions and it didn't help.

I am testing if my component reacts on window resize action.

Component Code

componentDidMount() {
    window.addEventListener('resize', this.handleResize);
  }

  componentWillUnmount() {
    window.removeEventListener('resize', this.handleResize);
  }

Failing tests code

 it('resize event is attached on componentDidMount', () => {
    window.addEventListener = spy();

    const component = mount(<TextField options={["aa", "ab"]} />);

    expect(window.addEventListener.calledOnce).to.equal(true);
  });

it('resize event removed attached on componentWillUnmount', () => {
    window.removeEventListener = spy();

    const component = mount(<TextField options={["aa", "ab"]} />, { attachTo: document.body.getElementsByTagName('div')[0] });

    component.detach();

    expect(window.removeEventListener.calledOnce).to.equal(true);
  });


/* Output
 1) resize resize event is attached on componentDidMount:
     AssertionError: expected undefined to equal true
      at Context.<anonymous> (test/AutoCompleteTextField.spec.js:524:51)

  2) resize resize event removed attached on componentWillUnmount:
     AssertionError: expected undefined to equal true
      at Context.<anonymous> (test/AutoCompleteTextField.spec.js:534:54)
*/

Packages involved:

  • "chai": "^3.5.0",
  • "chai-enzyme": "^0.5.1",
  • "cheerio": "^0.20.0",
  • "enzyme": "^2.4.1",
  • "jsdom": "^9.5.0",
  • "mocha": "^3.0.2",
  • "react": "^15.3.2",
  • "react-addons-test-utils": "^15.3.2",
  • "react-dom": "^15.3.2",
  • "sinon": "^1.17.6",

Updating those packages to the latest versions didn't help :/

@mscdex
Copy link
Contributor

mscdex commented Jan 6, 2017

Unless you can reproduce the issue without third party modules, I think this kind of question is better suited for the nodejs/help repo instead.

@mscdex mscdex added the question Issues that look for answers. label Jan 6, 2017
@kenany
Copy link
Contributor

kenany commented Jan 6, 2017

FWIW: git bisect reported ec2f13f as being the commit that your tests start failing at.

@kenany
Copy link
Contributor

kenany commented Jan 6, 2017

(so perhaps another case of #10492)

@Trott
Copy link
Member

Trott commented May 10, 2017

Closing as #10492 has been resolved. But if you're still experiencing this problem or if this otherwise shouldn't be closed, please comment and it can be re-opened.

@Trott Trott closed this as completed May 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment