đĨNut.js
Nuts.js is a new desktop automation library that we encourage use of as a test driver for simple applications. It allows you to both search for images on screen and interact with the desktop through keyboard, mouse, and more.
Classic approaches to desktop UI testing often include unique approaches per operating system and rely on selectors that are not human-readable. Nut.js on the other hand, is cross-platform and uses screenshots instead, which are easy enough for anyone to understand.
Helpful links for developing a test
Testing with Nut.js
Most tests in Nut.js follow a common pattern:
Wait for an image to appear
Click or validate the image
Go to 1
Here's what this looks like in code:
If any of these actions fail, like the image is not found, Nut.js will throw an error.
Using a test framework
Now, you'll likely want to make use of a testing framework like Mocha (our recommendation) or Jest. Here's an example of what that looks like:
Previewing images in VS Code
There is a helpful VS Code extension called Image Preview that will display previews of your image within the VS Code gutter as well as on hover.
Last updated