{"id":15022762,"url":"https://github.com/wechaty/puppet-mock","last_synced_at":"2026-02-23T03:17:18.548Z","repository":{"id":46781405,"uuid":"138896503","full_name":"wechaty/puppet-mock","owner":"wechaty","description":"Puppet Mocker for Wechaty (\u0026 A Puppet Template Starter)","archived":false,"fork":false,"pushed_at":"2022-10-03T07:43:42.000Z","size":280,"stargazers_count":50,"open_issues_count":6,"forks_count":15,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-22T00:51:48.905Z","etag":null,"topics":["mock","pupet","testing","wechaty"],"latest_commit_sha":null,"homepage":"https://paka.dev/npm/wechaty-puppet-mock","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wechaty.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}},"created_at":"2018-06-27T14:56:58.000Z","updated_at":"2025-09-04T03:52:18.000Z","dependencies_parsed_at":"2023-01-19T02:45:47.897Z","dependency_job_id":null,"html_url":"https://github.com/wechaty/puppet-mock","commit_stats":null,"previous_names":["wechaty/wechaty-puppet-mock","chatie/wechaty-puppet-mock"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/wechaty/puppet-mock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechaty%2Fpuppet-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechaty%2Fpuppet-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechaty%2Fpuppet-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechaty%2Fpuppet-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wechaty","download_url":"https://codeload.github.com/wechaty/puppet-mock/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechaty%2Fpuppet-mock/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29736172,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T02:24:00.660Z","status":"ssl_error","status_checked_at":"2026-02-23T02:22:56.087Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["mock","pupet","testing","wechaty"],"created_at":"2024-09-24T19:58:21.516Z","updated_at":"2026-02-23T03:17:18.526Z","avatar_url":"https://github.com/wechaty.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PUPPET-MOCK\n\n[![NPM Version](https://badge.fury.io/js/wechaty-puppet-mock.svg)](https://badge.fury.io/js/wechaty-puppet-mock)\n[![npm (tag)](https://img.shields.io/npm/v/wechaty-puppet-mock/next.svg)](https://www.npmjs.com/package/wechaty-puppet-mock?activeTab=versions)\n[![NPM](https://github.com/wechaty/wechaty-puppet-mock/workflows/NPM/badge.svg)](https://github.com/wechaty/wechaty-puppet-mock/actions?query=workflow%3ANPM)\n[![ES Modules](https://img.shields.io/badge/ES-Modules-brightgreen)](https://github.com/Chatie/tsconfig/issues/16)\n\n![chatie puppet](https://wechaty.github.io/wechaty-puppet-mock/images/mock.png)\n\n\u003e Picture Credit: \u003chttps://softwareautotools.com/2017/03/01/mocking-explained-in-python/\u003e\n\n[![Powered by Wechaty](https://img.shields.io/badge/Powered%20By-Wechaty-brightgreen.svg)](https://github.com/wechaty/wechaty)\n[![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-blue.svg)](https://www.typescriptlang.org/)\n\nPuppet Mocker \u0026 Starter Template for Wechaty, it is very useful when you:\n\n1. Want to test the Wechaty framework with a mock puppet, or\n1. You want to write your own Puppet implenmentation.\n\nThen `PuppetMock` will helps you a lot.\n\n## USAGE\n\n### Puppet Mock\n\n```ts\nimport { Wechaty }   from 'wechaty'\nimport { PuppetMock } from 'wechaty-puppet-mock'\n\nconst puppet  = new PuppetMock()\nconst wechaty = new Wechaty({ puppet })\n\nwechaty.start()\n```\n\n### Mocker \u0026 Environment\n\n```ts\nimport {\n  PuppetMock,\n  Mocker,\n  SimpleEnvironment,\n}                     from 'wechaty-puppet-mock'\n\nconst mocker = new Mocker()\nmocker.use(SimpleEnvironment())\n\nconst puppet = new PuppetMock({ mocker })\nconst wechaty = new Wechaty({ puppet })\n\nwechaty.start()\n\n// The Mocker will start perform the SimpleEnvironment...\n```\n\nSee: [SimpleEnvironment](src/mocker/environment.ts)\n\n## API Reference\n\n### Mocker\n\n```ts\nimport { Wechaty }  from 'wechaty'\nimport { PuppetMock, mock }   from 'wechaty-puppet-mock'\n\nconst mocker = new mock.Mocker()\nconst puppet = new PuppetMock({ mocker })\nconst bot = new Wechaty({ puppet })\n\nawait bot.start()\n\nmocker.scan('https://github.com/wechaty', 1)\n\nconst user = mocker.createContact()\nmocker.login(user)\n\nconst contact = mocker.createContact()\nconst room = mocker.createRoom()\n\nuser.say('Hello').to(contact)\ncontact.say('World').to(user)\n```\n\n## HELPER UTILITIES\n\n### StateSwitch\n\n```ts\nthis.state.on('pending')\nthis.state.on(true)\nthis.state.off('pending')\nthis.state.off(true)\n\nawait this.state.ready('on')\nawait this.state.ready('off')\n\n```\n\n### Watchdog\n\n```ts\n```\n\n### MemoryCard\n\n```ts\nawait memory.set('config', { id: 1, key: 'xxx' })\nconst config = await memory.get('config')\nconsole.log(config)\n// Output: { id: 1, key: 'xxx' }\n```\n\n## HISTORY\n\n### master v1.18 (Mar 14, 2022)\n\nUpgrade to Wechaty Puppet v1.18\n\n### v1.0 (Oct 29, 2021)\n\nRelease v1.0 of Puppet Mock\n\n1. v0.31: Support ES Modules\n\n### v0.25 (July 13, 2020)\n\n1. Rename `MockXXX` to `XXXMock` for keep the consistent naming style with `PuppetMock`.\n1. Export `mock` namespace and move all related modules under it.\n\n### v0.22 (June 4, 2020)\n\n`Mocker` Released. `Mocker` is a manager for controlling the behavior of the Puppet activities.\n\n1. Add `MockContact`, `MockRoom`, and `MockMessage` for `Mockers`\n1. Add `MockEnvironment` for mocking the server behaviors.\n1. Support `Wechaty#Contact.find()` from the `mocker.createContacts()`\n1. Support `Wechaty#Room.find()` from the `mocker.createRooms()`\n1. Support `message` event for `talker`, `listener`, and `room` of `MockMessage`\n\n### v0.0.1 (Jun 27, 2018)\n\nInitial version.\n\n`PuppetMock` is a skelton Puppet without do anything, it will make testing easy when developing Wechaty\n\n## AUTHOR\n\n[Huan LI](http://linkedin.com/in/zixia) \\\u003czixia@zixia.net\\\u003e\n\n\u003ca href=\"https://stackexchange.com/users/265499\"\u003e\n  \u003cimg src=\"https://stackexchange.com/users/flair/265499.png\" width=\"208\" height=\"58\" alt=\"profile for zixia on Stack Exchange, a network of free, community-driven Q\u0026amp;A sites\" title=\"profile for zixia on Stack Exchange, a network of free, community-driven Q\u0026amp;A sites\"\u003e\n\u003c/a\u003e\n\n## COPYRIGHT \u0026 LICENSE\n\n* Code \u0026 Docs © 2018 Huan LI \\\u003czixia@zixia.net\\\u003e\n* Code released under the Apache-2.0 License\n* Docs released under Creative Commons\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwechaty%2Fpuppet-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwechaty%2Fpuppet-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwechaty%2Fpuppet-mock/lists"}