Playing with a fake database trigger runner on my local dev environment.
This assumes that you have Docker running locally.
npm install # install dependencies
docker compose up -d # start the services
cp .env.sample .env # configure the application
Then edit the .env
file with a MongoDB URL, e.g.:
# MongoDB instance
DATABASE_URL=http://localhost:27019/some_database
Finally, prepare the database so it's configured for change streams pre and post images, and has some indexes:
npm run db:prepare
Listen for change stream events:
npm run listen
In another terminal, run some scenarios, or modify the data in MongoDB directly, using Compass or whatever tool you fancy.
npm run exec <PATH TO SCENARIO>
For now, this is using the same database as the development environment, and you need to run the listener process before the test suite:
npm run listen
# in another shell
npm test
I need to update the collection to provide the pre and post images. See this document for more information.
db.runCommand({ collMod: 'workspace_members', changeStreamPreAndPostImages: { enabled: true } })