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]: Support `import.meta.resolve` HOT 3
- [Feature]: Global / system wide config ?
- OpenJS Onboarding: Publish Security Policy
- OpenJS Onboarding: Create & Publish Project Charter
- [Bug]: `advanceTimersByTimeAsync` has inconsistent behavior regarding `setTimeout(x, 0)`
- Why do my unit tests slow down after 26 upgrading to the latest version of jest HOT 1
- [Bug]: Reporter interface has onTestCaseStart, but that hook is never called
- [Docs]: Difference between runner and testRunner? HOT 3
- [Bug]: Jest with ECMAScript modules importing a package that is itself an ECMAscript module fails HOT 1
- [Bug]: Validation warning for option "reporters" when using jest-junit to generate junit report
- [Bug]: Jest asserts truthy when comparing undefined with Map
- [Feature]: Tagging test block failures with 'step' description
- [Feature]: outputFile support for listTests option HOT 1
- [Bug]: `structuredClone` under jest fails `instanceof` check HOT 3
- [Bug]: `URLSearchParams#get(k, v)` is not implemented and uses `URLSearchParams#get(k)` instead HOT 1
- [Bug]: Unable to get Lit + Jest + Typescript + SWC Jest to work properly HOT 1
- [Bug]: When WorkerThreads are enabled the Jest fails to collect test coverage from untested files HOT 2
- [Bug]: `[email protected]` is pulling older jsdom v20 HOT 2
- [Bug]: Getting the compile time error
- [Bug]: Can't configure Jest to find tests under a `node_modules` directory HOT 2
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.