{"id":21039296,"url":"https://github.com/benjaminboruff/jest-test","last_synced_at":"2026-04-22T23:32:17.220Z","repository":{"id":91389241,"uuid":"71832722","full_name":"benjaminboruff/jest-test","owner":"benjaminboruff","description":"This repo should pass the jest test with Firebase imported","archived":false,"fork":false,"pushed_at":"2016-10-27T16:16:26.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-02T06:12:33.869Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benjaminboruff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-24T21:14:39.000Z","updated_at":"2023-06-29T12:23:40.000Z","dependencies_parsed_at":"2023-03-13T17:45:09.932Z","dependency_job_id":null,"html_url":"https://github.com/benjaminboruff/jest-test","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/benjaminboruff/jest-test","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjaminboruff%2Fjest-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjaminboruff%2Fjest-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjaminboruff%2Fjest-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjaminboruff%2Fjest-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benjaminboruff","download_url":"https://codeload.github.com/benjaminboruff/jest-test/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjaminboruff%2Fjest-test/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32159954,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T17:06:48.269Z","status":"ssl_error","status_checked_at":"2026-04-22T17:06:19.037Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T13:38:45.741Z","updated_at":"2026-04-22T23:32:17.191Z","avatar_url":"https://github.com/benjaminboruff.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# This repo should pass the jest test with Firebase imported\n## From a Jest/FB team member : \"firebase is doing something funky, there is an open issue about it we haven't had time to fix it yet\".\nFirst, install all the node_modules\n\u003e `npm install`\n\nThen, before we do *anything else* make sure this setup passes the\njest test.\n\u003e `npm test`\n\nshould output to the console:\n\n```bash\nPASS  ./index.test.js\n jest with firebase\n   ✓ is at least loadable (5ms)\n\n Test Suites: 1 passed, 1 total\n Tests:       1 passed, 1 total\n Snapshots:   0 total\n Time:        1.895s\n Ran all test suites.\n```\n\nOur goal, now, is to see how installing, then setting up, a\njest-react-native preset *breaks* the babel-jest preprocessor's\nability to import the firebase module a la ES modules.\n\nThe\n[Jest tutorial on using react](https://facebook.github.io/jest/docs/tutorial-react.html#content) and the\n[Jest tutorial on using react-native](https://facebook.github.io/jest/docs/tutorial-react-native.html#content)\nare confusing, but the following additional modules seem to be needed:\n\n\u003e npm install --save react react-native\n\n\u003e npm install --save-dev jest-react-native babel-preset-react-native react-test-renderer\n\nThen configure your package.json file by adding a \"jest\" option with the `jest-react-native` preset, and *modifying* the \"babel\" option by *adding* a `react-native` preset:\n```js\n\"jest\": {\n    \"preset\": \"jest-react-native\"\n },\n\"babel\": {\n  \"presets\": [\n    \"latest\",\n    \"react-native\"\n  ]\n }\n```\nThen, let's try to run the test again:\n\u003e npm test\n\nYou should get something similar to:\n\n```bash\nFAIL  ./index.test.js\n ● Test suite failed to run\n\n   TypeError: Cannot read property 'defineProperties' of undefined\n\n     at node_modules/firebase/app-node.js:18:234\n     at Object.\u003canonymous\u003e (node_modules/firebase/app-node.js:23:260)\n     at Object.\u003canonymous\u003e (node_modules/firebase/firebase-node.js:8:16)\n     at Object.\u003canonymous\u003e (index.test.js:1:117)\n\nTest Suites: 1 failed, 1 total\nTests:       0 total\nSnapshots:   0 total\nTime:        2.074s\nRan all test suites.\nnpm ERR! Test failed.  See above for more details.\n```\n\nSo, right away, by installing and configuring the \"jest-react-native\" and \"react-native\" presets **breaks** our ability to \"import\" firebase! The fix is to `require` firebase (**not** `import`) in our `index.test.js` file and add a line that imports `react-native`. Without `import`ing `react-native` in *addition* to `require('firebase')`, firebase will not be included in the test file:\n```\nconst Firebase = require('firebase')\nimport React from 'react-native'\n```\nThen, run our test again and it should pass:\n```bash\nPASS  ./index.test.js\n jest with firebase\n   ✓ is at least loadable (4ms)\n\nTest Suites: 1 passed, 1 total\nTests:       1 passed, 1 total\nSnapshots:   0 total\nTime:        4.604s\nRan all test suites.\n```\n**WHY?** That's the question that needs to be answered!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenjaminboruff%2Fjest-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenjaminboruff%2Fjest-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenjaminboruff%2Fjest-test/lists"}