{"id":19890271,"url":"https://github.com/urish/web-bluetooth-mock","last_synced_at":"2025-05-02T18:30:56.258Z","repository":{"id":45985347,"uuid":"109333364","full_name":"urish/web-bluetooth-mock","owner":"urish","description":"Mock Implementation of Web Bluetooth (for tests)","archived":false,"fork":false,"pushed_at":"2023-05-10T12:40:48.000Z","size":21,"stargazers_count":17,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-20T13:40:48.865Z","etag":null,"topics":["iot","mock","testing-tools","web-bluetooth"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/urish.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-11-03T00:34:19.000Z","updated_at":"2025-04-05T01:34:11.000Z","dependencies_parsed_at":"2024-06-19T01:38:44.746Z","dependency_job_id":"7b7c493f-f2df-4140-8636-59286917eaa4","html_url":"https://github.com/urish/web-bluetooth-mock","commit_stats":{"total_commits":18,"total_committers":4,"mean_commits":4.5,"dds":0.2222222222222222,"last_synced_commit":"adf26073f5f4725d78652c597a3ce2394a5e7a68"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urish%2Fweb-bluetooth-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urish%2Fweb-bluetooth-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urish%2Fweb-bluetooth-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urish%2Fweb-bluetooth-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/urish","download_url":"https://codeload.github.com/urish/web-bluetooth-mock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252088267,"owners_count":21692765,"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":["iot","mock","testing-tools","web-bluetooth"],"created_at":"2024-11-12T18:13:36.187Z","updated_at":"2025-05-02T18:30:55.948Z","avatar_url":"https://github.com/urish.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Web Bluetooth API Mock\n\n[![Build Status](https://travis-ci.org/urish/web-bluetooth-mock.png?branch=master)](https://travis-ci.org/urish/web-bluetooth-mock)\n\nMock for the Web Bluetooth API, useful for testing code that uses Web Bluetooth.\n\nCopyright (C) 2017, Uri Shaked. Licensed under the terms of MIT License.\n\n## Installation\n\nThe Web Bluetooth API mock is available on npm, and can be installed by running:\n\n    npm install --save-dev web-bluetooth-mock\n\n## Usage example\n\nThe following code will test whether a method called `connectToDevice()`\nscans for a device containing a `0xffe0` service and connects to it. \nIt assumes [jest](https://facebook.github.io/jest/) testing framework, though the code\ncan be very easily adjusted for a different testing framework.\n\n```javascript\nimport { WebBluetoothMock, DeviceMock } from './web-bluetooth.mock';\n\ndescribe('connectToDevice', () =\u003e {\n  it('should connect to bluetooth device', async () =\u003e {\n    // Setup a Mock device and register the Web Bluetooth Mock\n    const device = new DeviceMock('Dummy-Device', [0xffe0]);\n    global.navigator = global.navigator || {};\n    global.navigator.bluetooth = new WebBluetoothMock([device]);\n\n    // This is a Jest specific mock, change to just `spyOn(...)` for Jasmine\n    jest.spyOn(device.gatt, 'connect');\n\n    // Calling the method we want to be tested\n    await connectToDevice();\n\n    // Checking if the function has been invoked. This also means\n    // that requestDevice() has been called with a filter that matches\n    // the device we defined above.\n    expect(device.gatt.connect).toHaveBeenCalled();\n  });\n});\n```\n\nFor a more complete example, check out [muse-js library tests](https://github.com/urish/muse-js/blob/master/src/muse.spec.ts).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furish%2Fweb-bluetooth-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Furish%2Fweb-bluetooth-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furish%2Fweb-bluetooth-mock/lists"}