{"id":15631274,"url":"https://github.com/zirho/firebase-unit-test","last_synced_at":"2025-04-30T03:47:07.394Z","repository":{"id":71209078,"uuid":"78574189","full_name":"zirho/firebase-unit-test","owner":"zirho","description":"Unit tests for Firebase","archived":false,"fork":false,"pushed_at":"2017-01-11T19:02:12.000Z","size":138,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-30T03:47:01.175Z","etag":null,"topics":["database","firebase","firebase-console","unit-testing"],"latest_commit_sha":null,"homepage":"http://zirho.github.io/2017/01/11/firebase-unit-test/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zirho.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2017-01-10T21:08:58.000Z","updated_at":"2020-12-24T19:59:09.000Z","dependencies_parsed_at":"2023-03-16T20:01:01.439Z","dependency_job_id":null,"html_url":"https://github.com/zirho/firebase-unit-test","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zirho%2Ffirebase-unit-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zirho%2Ffirebase-unit-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zirho%2Ffirebase-unit-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zirho%2Ffirebase-unit-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zirho","download_url":"https://codeload.github.com/zirho/firebase-unit-test/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251638756,"owners_count":21619662,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["database","firebase","firebase-console","unit-testing"],"created_at":"2024-10-03T10:39:47.791Z","updated_at":"2025-04-30T03:47:07.388Z","avatar_url":"https://github.com/zirho.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Firebase Unit Test\n\nDemonstrate how to perform automated unit tests against database and rules\n\n# Prerequisite \n\n#### install node\n\n#### install yarn package manager\n\nhttps://yarnpkg.com/en/docs/install\n\n#### install firebase-tools globally\n\n```\nyarn global add firebase-tools\n```\n\n\n# Installation\n\n## Clone and init the repo \n\n```\ngit clone https://github.com/zirho/firebase-test\ncd firebase-test\nyarn install\n```\n\n## Create and init firebase app\n\n**Skip this if you already have a project setup and initiated**\n\n#### Create a project\n\nGo to https://console.firebase.google.com/project/\n\nCreate a new project\n\n#### Get project configs\n\nUpdate firebase.config.js with what your project gave you\n\n```\nvi src/firebase.config.js\n```\n\nIt should look something like this\n```\nexport default {\n  apiKey: 'your-app-key',\n  authDomain: 'your-app-domain.firebaseapp.io',\n  databaseURL: 'https://your-firebase-database-url.firebaseio.com',\n}\n```\n\n#### Init the project \n\n* refrence https://github.com/firebase/firebase-tools\n```\nfirebase login\nfirebase init\n```\n\nFollow the instructions\n * select database\n * select project name that you created\n * select default for other options\n\n#### Get an admin credential file\n\n * Go to \"Project Setting\" on firebase console.\n * Select \"SERVICE ACCOUNTS\" tab\n * Click on \"GENERATE NEW PRIVATE KEY\" at the bottom\n * It will download a creds json file\n * Copy that file to root folder of your project and rename it as 'firebase-admin.json'\n\n For Mac user\n\n ```\n cp ~/Downloads/[downloaded file name].json ./firebase-admin.json\n ```\n\n#### Apply new rules for firebase database\n\nUpdate `./database.rules.json` as you needed\n\nAnd deploy it\n```\nfirebase deploy --only database\n```\n\n## Run tests\n\n#### Run test once\n\n```\nyarn test-once\n```\n\n#### Run tests any time *.js file updates (watch and run tests)\n\n```\nyarn test\n```\n\n#### Run tests as an authenticated user\n\nPick a UID from firebase console \u003e Authentication \u003e USERS \n\nPut the UID to the test\n\n```\nvi src/auth.test.js\n```\n```\ndescribe('Authenticated firebase', () =\u003e {\n  let authedFirebase\n  const UID = 'vl7GjxgIRre1sD0ftesttesttesttest'\n...\n...\n```\n\n#### Default tests will be successful, if your database has `/user/joshua` available\n\n![data exmaple](./guide/data-example.png \"data example\")\n\n![test result](./guide/result.png \"successfully ran tests\")\n\n\n**Welcome to contribute**\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzirho%2Ffirebase-unit-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzirho%2Ffirebase-unit-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzirho%2Ffirebase-unit-test/lists"}