Comments (7)
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.
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.
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.
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.
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.
Yeah unfortunately I don't think we'll be fixing this in jest. Feel free to reopen if you feel strongly.
from jest.
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)
- [Feature]: Allow to customize the serializable properties during error report
- [Bug]: Wrong diff for objectContaining
- [Feature]: Custom diff for custom asymmetric matcher
- [Docs]: Adopt OpenJS Code Of Conduct HOT 2
- [Feature]: toContainSnapshot and toContainInlineSnapshot
- [Bug]: Error Message links to URL with . at the end, causeing wrong url to be opened HOT 1
- [Bug]: Jest does not recognise Vite suffixes applied to imports HOT 1
- [Docs]: Update Footer On Jest Website
- [Feature]: Ability to dispatch spec files to jest non-interactively
- Failed build: Node Nightly CI HOT 16
- [Feature]: Report duplicate test names HOT 2
- [Feature]: New hook `beforeEach.successive` which is like beforeEach, but only for successive tests in the suite HOT 1
- [Bug]: Unexpected token 'export' when Jest test imports d3-array (3.2.4) HOT 1
- [Bug]: ReferenceError: CSS is not defined HOT 1
- [Feature]: Option to support `Error#cause` in snapshots for Jest29 HOT 3
- [Bug]: Using `projects` option does not "copy the root-level configuration options to each individual child configuration during the test run"
- [Feature]: The ability of `toHaveProperty` to parse dots in property name is so evil. Please remove it.
- [Bug]: Error while running watch
- OpenJS Onboarding: Document Core Infrastructure By Filling Out Google Form HOT 1
- [Feature]: Support `import.meta.resolve` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jest.