Game Automation

Test your games with Node.js

Automate any game with image recognition, pixel detection, and precise input control. Perfect for E2E testing, QA automation, and regression testing during game development.

Note: Always respect game terms of service. Use responsibly for personal projects, testing, and allowed automation.

game.e2e.test.ts
import { describe, it, expect } from "vitest";
import {
    screen, mouse, Button, keyboard,
    straightTo, centerOf, imageResource, sleep
} from "@nut-tree/nut-js";
import { useNlMatcher } from "@nut-tree/nl-matcher";

useNlMatcher();

describe("Main Menu", () => {
    it("should start a new game", async () => {
        const playBtn = await screen.find(
            imageResource("play-button.png")
        );
        await mouse.move(straightTo(centerOf(playBtn)));
        await mouse.click(Button.LEFT);

        // Verify loading screen appears
        const loading = await screen.find(
            imageResource("loading-screen.png")
        );
        expect(loading).toBeDefined();
    });

    it("should show the HUD after loading", async () => {
        await screen.waitFor(
            imageResource("hud-health-bar.png"),
            10_000
        );
        const minimap = await screen.find(
            imageResource("minimap.png")
        );
        expect(minimap).toBeDefined();
    });
});

Everything you need for game testing

nut.js provides the building blocks for sophisticated game automation.

🎯

Multiple Search Methods

Find elements by image templates, text OCR, pixel colors, or screen regions.

🔍

Pixel Detection

Monitor health bars, mana pools, and status indicators by color.

🖱️

Human-like Input

Configurable mouse movement speed and patterns to avoid detection.

High Performance

Optimized for real-time game automation with minimal latency.

Monitor game state in real-time

Read health bars, detect enemies, analyze minimaps, and respond to in-game events instantly.

Pixel color detection

Monitor specific screen locations for color changes

Region capture

Capture specific areas for analysis or processing

Multi-template matching

Search for multiple patterns simultaneously

detection.ts
import { screen, colorAt, Region } from "@nut-tree/nut-js";

// Health bar monitoring
async function monitorHealth() {
    const healthBarRegion = new Region(100, 50, 200, 20);

    while (true) {
        // Get pixel color at health bar position
        const healthColor = await colorAt(
            screen,
            { x: 150, y: 55 }
        );

        // Red = low health, Green = full health
        if (healthColor.R > 200 && healthColor.G < 100) {
            await useHealthPotion();
        }

        await sleep(100);
    }
}

// Screen region capture for analysis
async function analyzeGameState() {
    const minimapRegion = new Region(1720, 800, 200, 200);
    const minimap = await screen.grabRegion(minimapRegion);
    // Process minimap for enemy positions, etc.
}

What can you automate?

E2E Testing

Validate complete gameplay flows end-to-end—from menu navigation to in-game interactions—across platforms.

Regression Testing

Catch visual and functional regressions between builds by replaying test scenarios automatically after every release.

QA Automation

Reduce manual QA effort by scripting repetitive test cases like UI checks, tutorial flows, and settings verification.

Gameplay Scripting

Script complex in-game sequences for stress testing, performance benchmarking, or reproducing hard-to-trigger bugs.

Ready to build your game bot?

Get started with nut.js and build sophisticated game automation in minutes.