Giter Club home page Giter Club logo

Comments (7)

sophiebits avatar sophiebits commented on May 2, 2024

I can't reproduce this. I made a file __tests__/foo-test.js with the following contents:

describe('footest', function() {
  it('checks the foo', function() {
    var x = {};
    console.log(x.y === undefined);
  });
});

and running jest gives the output:

Using Jest CLI v0.1.15
Found 1 matching tests...
 PASS  __tests__/foo-test.js (0.012s)
true
1 tests passed (1 total)
Run time: 0.71s

Let me know if I'm missing something.

from jest.

ruanwz avatar ruanwz commented on May 2, 2024

This seems to be tricky, when I use react, jest, fluxoor and firebase together,somehow the result is that after loading these code, myobj[not_existed_key] === undefined is false. Only typeof myobj[not_existed_key] == 'undefined' is true

The example app is below:
https://github.com/ruanwz/example-react

➜  example-react git:(master) ✗ npm test

> [email protected] test /tmp/example-react
> jest

Found 1 matching tests...
 FAIL  __tests__/my_component_test.coffee (0.487s)
● TalkBox › it has a video element
  - Error: Invariant Violation: mergeObjectsWithNoDuplicateKeys(): Tried to merge two objects with the same key: room
        at invariant (/tmp/example-react/node_modules/react/lib/invariant.js:52:19)
        at /tmp/example-react/node_modules/react/lib/ReactCompositeComponent.js:548:46
        at objMap (/tmp/example-react/node_modules/react/lib/objMap.js:41:23)
        at mergeObjectsWithNoDuplicateKeys (/tmp/example-react/node_modules/react/lib/ReactCompositeComponent.js:547:3)
        at mergedResult [as getInitialState] (/tmp/example-react/node_modules/react/lib/ReactCompositeComponent.js:576:12)
        at ReactCompositeComponentMixin.mountComponent (/tmp/example-react/node_modules/react/lib/ReactCompositeComponent.js:926:48)
        at null.mountComponent (/tmp/example-react/node_modules/react/lib/ReactPerf.js:57:21)
        at ReactCompositeComponentMixin.mountComponent (/tmp/example-react/node_modules/react/lib/ReactCompositeComponent.js:952:44)
        at null.mountComponent (/tmp/example-react/node_modules/react/lib/ReactPerf.js:57:21)
        at ReactComponent.Mixin._mountComponentIntoNode (/tmp/example-react/node_modules/react/lib/ReactComponent.js:561:25)
        at ReactReconcileTransaction.Mixin.perform (/tmp/example-react/node_modules/react/lib/Transaction.js:159:20)
        at ReactComponent.Mixin.mountComponentIntoNode (/tmp/example-react/node_modules/react/lib/ReactComponent.js:537:19)
        at Object.ReactMount._renderNewRootComponent (/tmp/example-react/node_modules/react/lib/ReactMount.js:309:25)
        at Object._renderNewRootComponent (/tmp/example-react/node_modules/react/lib/ReactPerf.js:57:21)
        at Object.ReactMount.renderComponent (/tmp/example-react/node_modules/react/lib/ReactMount.js:359:32)
        at Object.renderComponent (/tmp/example-react/node_modules/react/lib/ReactPerf.js:57:21)
        at Object.ReactTestUtils.renderIntoDocument (/tmp/example-react/node_modules/react/lib/ReactTestUtils.js:57:18)
        at Spec.<anonymous> (/tmp/example-react/public/__tests__/my_component_test.coffee:47:15)
        at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
  - Error: Did not find exactly one match for tag:video
        at Object.ReactTestUtils.findRenderedDOMComponentWithTag (/tmp/example-react/node_modules/react/lib/ReactTestUtils.js:173:13)
        at Spec.<anonymous> (/tmp/example-react/public/__tests__/my_component_test.coffee:52:23)
        at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
1 tests failed, 0 tests passed (1 total)

from jest.

ruanwz avatar ruanwz commented on May 2, 2024

I try to get the latest firebase lib, then run again, now it works:

➜  example-react git:(latest-firebase-simple-login) ✗ npm test

> [email protected] test /tmp/test/example-react
> jest

Found 1 matching tests...
 PASS  __tests__/my_component_test.coffee (0.495s)
1 tests passed (1 total)
Run time: 1.497s

I think this is not a bug of jest/react, but use typeof myobj[not_existed_key] == 'undefined' might help to avoid some conflicts like this in the future.

from jest.

sophiebits avatar sophiebits commented on May 2, 2024

Odd that Firebase breaks it, but this seems like a bug in jest. If I write

undefined = 2;
console.log(typeof undefined);

then I get undefined when executing the code directly but number within jest.

from jest.

 avatar commented on May 2, 2024

Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.

from jest.

cpojer avatar cpojer commented on May 2, 2024

Yeah unfortunately I don't think we'll be fixing this in jest. Feel free to reopen if you feel strongly.

from jest.

github-actions avatar github-actions commented on May 2, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

from jest.

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.