{"id":22730264,"url":"https://github.com/ert78gb/google-pubsub-emulator","last_synced_at":"2025-10-07T06:04:47.528Z","repository":{"id":38848129,"uuid":"80431949","full_name":"ert78gb/google-pubsub-emulator","owner":"ert78gb","description":"Google PubSub Emulator wrapper to nodejs","archived":false,"fork":false,"pushed_at":"2024-02-13T08:18:04.000Z","size":546,"stargazers_count":32,"open_issues_count":4,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-16T00:14:33.038Z","etag":null,"topics":["emulator","google-cloud-pubsub","test","wrapper"],"latest_commit_sha":null,"homepage":"","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/ert78gb.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG.md","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-30T15:07:38.000Z","updated_at":"2024-05-31T19:50:52.000Z","dependencies_parsed_at":"2023-01-22T22:15:51.766Z","dependency_job_id":"3a09ec6b-2448-4d10-a08c-e4248f999b91","html_url":"https://github.com/ert78gb/google-pubsub-emulator","commit_stats":{"total_commits":159,"total_committers":4,"mean_commits":39.75,"dds":0.5345911949685535,"last_synced_commit":"17eabe4ca141f9c26fdbd1565c6f5eacd96cde9a"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/ert78gb/google-pubsub-emulator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ert78gb%2Fgoogle-pubsub-emulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ert78gb%2Fgoogle-pubsub-emulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ert78gb%2Fgoogle-pubsub-emulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ert78gb%2Fgoogle-pubsub-emulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ert78gb","download_url":"https://codeload.github.com/ert78gb/google-pubsub-emulator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ert78gb%2Fgoogle-pubsub-emulator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264284266,"owners_count":23584672,"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":["emulator","google-cloud-pubsub","test","wrapper"],"created_at":"2024-12-10T18:13:58.002Z","updated_at":"2025-10-07T06:04:42.494Z","avatar_url":"https://github.com/ert78gb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![CI](https://github.com/ert78gb/google-pubsub-emulator/workflows/CI/badge.svg)\n![CodeQL](https://github.com/ert78gb/google-pubsub-emulator/workflows/CodeQL/badge.svg)\n\nGoogle Cloud PubSub Emulator\n===============================\n\nThis package helps to start / stop [Google Cloud Pub/Sub Emulator](https://cloud.google.com/sdk/gcloud/reference/beta/emulators/pubsub/) with javascript.\nPerfect to support unit testing when you need the local emulator start in unit / half integration test.\n\nThe wrapper sets PUBSUB_EMULATOR_HOST and GCLOUD_PROJECT environment variables.\n\nFrom 2.0.0 @google-cloud/pubsub moved to the peer dependencies.\n\n#Prerequisites\nTo use the emulator you need to install [Google Cloud SDK](https://cloud.google.com/sdk/downloads)\n\n#Installation\n```\nnpm install google-pubsub-emulator --save-dev\n```\n\n#Usage\nI think the package is the most suitable for unit testing.\n \n```javascript\nconst {PubSub} = require('@google-cloud/pubsub');\nconst Emulator = require('google-pubsub-emulator');\n\ndescribe('test suit', ()=\u003e{\n    process.env.GCLOUD_PROJECT = 'project-id'; // Set the gcloud project Id globally\n\n    let emulator;\n    \n    before(()=\u003e{\n        const options = {\n            debug:true, // if you like to see the emulator output\n            topics: [\n                'projects/project-id/topics/topic-1' // automatically created topic\n            ]\n        };\n        \n        emulator = new Emulator(options);\n        \n        return emulator.start();\n    });\n    \n    after(()=\u003e{\n        return emulator.stop();\n    });\n    \n    it('test case', ()=\u003e{\n        // your test\n    });\n})\n\n```\n\n## Options\n\nparameter (type) | default value | description\n----------|---------------|-------------------\nproject (string) | empty | This variable is gcloud project Id. If it is empty, GCLOUD_PROJECT environment variable will be used. Either you should set it directly or the environment variable should be set.\ndataDir (string) | empty | The emulator creates a directory where the project files are stored. If it is empty the emulator default value will be used. You could set relative ./directory or absolute path /tmp/dir1/dir2/. If this directory does not exist, it will be created.\nclean (boolean) | true | If dataDir value is set and 'clean' value is true then the package deletes the dataDir. The package **does not** delete the gcloud emulator default directory. \nhost (string) | empty | If it is empty the'localhost' of google default value is used. It can take the form of a single address (hostname, IPv4, or IPv6)\nport (number) | empty | If it is empty the emulator selects a random free port.\ndebug (boolean) | false | If it is true, it writes the console.logs of the emulator onto the main process console.\ntopics (array) | [] | If it is contains values then the wrapper create the missing topics. You should set the full identifier of the topic 'projects/\u003cproject-name\u003e/topics/\u003ctopic-name\u003e'\n\n## Methods\n\nname | description\n-----|------------\nstart | Starts the emulator and returns a Promise.\nstop | Stops the emulator and returns a Promise.\n\n#License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fert78gb%2Fgoogle-pubsub-emulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fert78gb%2Fgoogle-pubsub-emulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fert78gb%2Fgoogle-pubsub-emulator/lists"}