Monkey testing — Let’s break things!
gremlins.js + cypress.io
What is Monkey Testing?
It’s a technique where we intentionally try to break or crash the application — this could be by entering random inputs, clicking or scrolling randomly, and generally interacting with the application in a way which isn’t considered ‘normal’.

Why should you do it?
- It’s cheap — even when done manually, and further into this post I’ll show how we can automate it
- It uncovers issues or errors which may not have been considering through the ‘normal’ user flow
- When used to an extreme scale, it can be an addition to reliability/resilience testing for your application — if I perform an action 100 times in quick succession, will the application fall over?
- It’s another step towards automating as much as possible — exploratory/destructive testing has always been seen as a manual tester skill set
How can I get started?
We are going to be using gremlin.js in the examples below:
Gremlins.js simulates random user actions: gremlins click anywhere in the window, enter random data in forms, or move the mouse over elements that don’t expect it. Their goal: triggering JavaScript errors, or making the application fail.
Go to the gremlin.js repository — from here generate a bookmarklet for ad-hoc browser usage or write more advanced tests in JavaScript — they also have examples of usage with Cypress, which makes it simple to extend your current test frameworks.
The bookmarklet
You’ll be able to select from 5 different gremlins, each have their own behaviours, so you may want to select each individually and observe how it interacts with your application.

When you are happy with your selection, drag the link to your bookmarks, go to your target website and select the bookmark — the gremlins will run on that page.
If you really want to break things, select ‘All together’ to run all gremlins in parallel 👹

What type of issues can result from this?
Let’s use the example above, we would be looking for issues related to —
- Character limits
- External links
- Field validation
- Form navigation
- Form submission
- JavaScript errors
- Page formatting
Integrating with Cypress
Read here first to get a brief introduction— then I’d suggest cloning the whole repo., and executing the cypress tests — you’ll get a better understanding of the code and can customise as needed.

On a basic level it’s similar to the bookmarklet — you can select the gremlin specie, the strategy type, how many instances to run and the delay between each execution.
There is a lot of customisation in terms of targets, element inclusion/exclusion, and custom logging during test execution.
Once you are comfortable with the code and implementation, gremlin.js can be installed in a new project, or your existing project with:
npm i gremlins.js
Conclusion
- Monkey testing isn’t new — but there is a lot of potential for innovative approaches when paired with automation
- It’s chaotic, but it doesn’t mean you can’t take a controlled approach — there is a lot of customisation available, you could write full test suites with these tools