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)
- [Bug]: module is not mocked if there's signal input in spec file (angular)
- [Bug]: isEqual with large Float64Arrays is slow HOT 1
- [Feature]: Provide console logs per testcase to reporter
- [Bug]: require.main has invalid value null
- [Bug]: toThrow fails if error object contains a cause property
- [Feature]: add `expect(spy).toHaveResolvedWith` for spies on async functions
- [Feature]: Replace `chalk` dependency with a lighter alternative HOT 3
- [Feature]: make PRINT_LIMIT configurable
- [Feature]: Show which project failed when a `preset` fails to load HOT 1
- [Bug]: Calling ts.createSourceFile in a test file hangs with Typescript 5.x.x
- [Bug]: [jest-runner] loses error `stack` property for failed test when sends a message to jest
- [Bug]: No way to use inline snapshots without Babel
- [Docs]: .tocontainequalitem() explanation is ambiguous HOT 1
- [Feature]: Expect the assertion to eventually pass
- [Bug]: CR (`"\r"`) in the test name breaks snapshot testing
- [Bug]: Snapshot testing does not detect the difference between CR ("\r") and LF ("\n")
- [Bug]: Require is not found while Mocking Dynamodb.mjs HOT 2
- [Bug]: modulePathIgnorePatterns should not cause "no tests found"
- [Docs]: Document that `--runInBand` forks a worker when `--workerIdleMemoryLimit` is set HOT 3
- [Feature]: Bump `jsdom` versions from 22 to 24 HOT 1
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.