Testing is boring when you see messages like asdasdassdas
, kemdlwemkd
, gegsfgsdfsd
on the chat screen.
This internal tool for Stream will generate a nice set of data (which is pleasant for eye of dev and tester), which contain reactions, attachments, enriched urls replies etc etc. Feel free to add comments in issues sections for improvement :)
- Clone the repo
# Clone the repo
git clone [email protected]:GetStream/stream-chat-test-data-cli.git
# Go to directory
cd stream-chat-test-data-cli
# Install the dependencies and link the repo
yarn; yarn link;
# Install stream chat
yarn add stream-chat
- Create config file.
# Create a copy of your config.
cp config.js.template dev.config.js
NOTE For SDK Teams
You can use the template file for corresponding team e.g., flutter.config.js.template contains appUsers from Flutter team.
cp flutter.config.js.template dev.config.js
NOTE: dev.config.js
gets used by default in all commands. Each SDK team will maintain their own config file for their dev app, on their local environment.
- Please set the credentials in both the files such as
apiKey
andsecret
indev.config.js
. Please check other parameters as well.
Most basic command that you will use is create-channels
. It serves two purposes:
- Create initial data for the app
- And reset/repopulate the messages on channels at some point in future. Data will be reset only for the channels with prefix specificed in config.
You may want to pay attention to few config params before running the command for first time
- apiKey and secret (ofc)
- channelType
- channelIdPrefix
- appUsers
# By default command uses dev.config.js
create-channels
You can create multiple config files in root directory.
create-channels --config custom.config.js
Error: getaddrinfo ENOTFOUND chat-us-east-staging.stream-io-api.com
Comment out the baseUrl
in the config file
Docs for all the commands is available here - https://github.com/GetStream/stream-chat-test-data-cli/blob/master/doc.md
Following config options are available
https://github.com/GetStream/stream-chat-test-data-cli/blob/master/config.js.template
This will only reset channels with channelIdPrefix
, mentioned in your config file.
Use reset-all-channels instead, if you want to reset all the channels.
reset-channels
- Change channelIdPrefix in config
- Set any
customProperties
if you want
create-channels
reset-all-channels
add-messages --channelId "default-channel-0" --number 50
So basically you want to add bunch of messages to channel, but not from your current logged in user.
# 50 messages will be added from other members of channel, other than vishal
add-messages --channelId "default-channel-0" --number 50 --excludeUser "vishal"
# 30 new randomly generated users will be added as members.
create-channel-members --channelId "default-channel-0" --number 30
create-user --id "vishal" --name "Vishal Narkhede" --image "user"
create-app-users --number 10
There are bunch of more commands available, please check the next Command Docs part.
You can use bin/playground.js
for it.
playground
If you want to add a new command:
- Create a script file
cp bin/playground.js bin/<command-name>.js
- Add your command to
package.json
file,
...
"bin": {
...
"<command-name>": "bin/<command-name>.js"
}
- Relink the project
yarn unlink && yarn link
- Try it
<command-name>
- To add the command to command docs
Go to bin/generate-docs.js
and add new command to executables
array.
And then
yarn build