gitmyhub

gremlins.js

JavaScript ★ 9.1k updated 3y ago

Monkey testing library for web apps and Node.js

A JavaScript testing library that stress-tests web apps by unleashing random clicks, typing, and scrolling, monkey testing that finds edge-case bugs your scripted tests never think to try.

JavaScriptCypressPlaywrightsetup: easycomplexity 2/5

gremlins.js is a testing tool that finds bugs in web applications by doing random, unpredictable things to them. It clicks on random spots, types nonsense into form fields, scrolls in unexpected directions, and generally behaves like the most chaotic user imaginable. The idea is that if your application can survive a few hundred random actions without crashing or throwing errors, it is probably solid enough for real users.

This approach is called monkey testing or fuzz testing, a technique borrowed from mobile app development where similar tools have been used for years. For web applications built with a lot of JavaScript, random-action testing can reveal edge cases that manual testers and scripted tests never think to try, like what happens if someone submits a form with emoji in a number field or scrolls to the bottom of the page while a modal is opening.

The library works through two types of agents: gremlins and mogwais. Gremlins are the ones causing chaos, clicking, typing, scrolling, touching. Mogwais are observers that monitor how the application is holding up, tracking frame rates, watching for JavaScript errors, and logging what is happening. A built-in mogwai called Gizmo automatically stops the test after ten errors so you can focus on fixing the first batch of problems before the list grows unmanageable.

You can control which gremlins run, how many actions they take, how fast they work, and what they consider an error. Custom gremlins can be written as plain JavaScript functions and added to the horde. The tool integrates with Cypress and Playwright for teams that run it as part of a testing pipeline. It is also available as a bookmarklet, a small saved browser link you can use to attack any web page without installing anything.

Where it fits