1.10.2 • Published 2 years ago

wechaty-mocker v1.10.2

Weekly downloads
6
License
Apache-2.0
Repository
github
Last release
2 years ago

wechaty-mocker

NPM Version NPM TypeScript

Wechaty Mocker

Credit: The Matrix

Wechaty Mocker provides the mocking system for testing Wechaty Chatbots.

What is this

This is an essential component when you are trying to test your wechaty puppet implementation. This project is aim to provide a tool that helps you mock a wechat account, which could mock an account with mock contacts and mock rooms, and generate messages (in different types), events (like friendship events, room events etc) for you.

Why do we need this

Currently there are several wechaty puppets available, like wechaty-puppet-macpro or wechaty-puppet-padplus, but we don't know how many instance we could run on a 2 core cpu 4G memory machine, when it came to industry usage of these project, the performance is a key attribute. The reason that we don't know the answer to the question is that we can not evaluate this, there is no test server that we can use since we are trying to connect to Wechat. Thus we need a mock tool to mock these things so we can do some pressure testing on our puppet code, then we will have confidence to say how many wechat accounts could be run on a 2 core cpu 4G memory machine. From that point, we will be able to find a number to optimize.

Features

  • Generate wechat account, includes wxid, name, weixin, avatar, gender
  • Generate contacts and rooms: according to config (contact count, room count, room member distribution)
  • Emit messages: according to config (frequency, message types, room message ratio and contact message ratio)
  • Emit friendship events: according to config (frequency) emit friendship events
  • Emit room events; according to config (frequency of different room events)

Usage

import { createFixture } from 'wechaty-mocker'

for await (const fixture of createFixture()) {
  // ...
}

Reference

To be written.

Mocker

ContactMock

RoomMock

MessageMock

History

master

v0.2 (July 25, 2020)

  1. Move createFixture from wechaty and mocker.* from wechaty-puppet-mock to prevent circler dependencies.

Author

Huan LI (李卓桓), Microsoft AI MVP, zixia@zixia.net

Profile of Huan LI (李卓桓) on StackOverflow

Copyright & License

  • Docs released under Creative Commons
  • Code released under the Apache-2.0 License
  • Code & Docs © 2018 Huan LI \zixia@zixia.net\
1.11.3

2 years ago

1.11.2

2 years ago

1.11.1

2 years ago

1.10.2

2 years ago

1.10.1

2 years ago

1.0.3

3 years ago

1.0.1

3 years ago

0.9.2

3 years ago

0.9.1

3 years ago

0.7.3

3 years ago

0.7.2

3 years ago

0.5.4

4 years ago

0.5.3

4 years ago

0.5.5

4 years ago

0.5.2

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.0.5

4 years ago

0.0.3

4 years ago