explaingit

segment-boneyard/nightmare

19,767JavaScriptAudience · developerComplexity · 3/5DormantSetup · easy

TLDR

JavaScript library for automating browser tasks like clicking, typing, and scraping using real Chromium via Electron. No longer maintained but documented for reference.

Mindmap

mindmap
  root((Nightmare))
    What it does
      Control browser
      Navigate pages
      Extract content
    How it works
      Electron runtime
      Real Chromium
      Promise chains
    Use cases
      Web scraping
      Form automation
      UI testing
    Tech stack
      JavaScript
      Node.js
      Electron
    Companion tools
      Daydream recorder
      Niffy visual testing

Things people build with this

USE CASE 1

Scrape content from websites that don't have a public API by navigating pages and extracting text or links.

USE CASE 2

Automate form submissions and data entry tasks on websites by typing into fields and clicking buttons.

USE CASE 3

Test web application UI by simulating user interactions and verifying that pages behave correctly.

Tech stack

JavaScriptNode.jsElectronChromium

Getting it running

Difficulty · easy Time to first run · 5min

Library is unmaintained; may have compatibility issues with modern Node.js versions.

License could not be detected automatically. Check the repository's LICENSE file before use.

In plain English

Nightmare is a JavaScript browser automation library built on top of Electron (the same technology used by the VS Code desktop app). It lets you write scripts that control a real browser, navigating to pages, typing into fields, clicking buttons, waiting for elements to appear, and reading content back out, all from Node.js code. It is no longer maintained, but is documented here for reference. The key design goal was to make browser automation feel like a simple, readable sequence of steps rather than deeply nested callback code. You chain actions together, and each action in the chain waits for the previous one to complete before running. For example, a script to search DuckDuckGo would navigate to the page, type a query into the search box, click the search button, wait for results to appear, and then extract a link, all as a linear chain of method calls. Results are returned as JavaScript Promises. It was designed for two main use cases: automating tasks on websites that have no public API (scraping or form submission), and UI testing where you want to verify that a web page behaves correctly when a user interacts with it. Electron, the underlying runtime, is essentially a full Chromium browser, so Nightmare executes in a real browser context rather than a simulated one. The companion tool Daydream is a Chrome extension that watches your own browsing and generates Nightmare scripts automatically. Niffy is a visual testing tool that uses Nightmare to take screenshots and compare them across releases to catch unintended UI changes. The library is written in JavaScript and runs on Node.js.

Copy-paste prompts

Prompt 1
Show me how to write a Nightmare script that navigates to a website, fills out a form, and submits it.
Prompt 2
How do I use Nightmare to scrape product listings from a website and extract prices and descriptions?
Prompt 3
Write a Nightmare script that logs into a website, waits for a page to load, and takes a screenshot.
Prompt 4
How can I use Nightmare to test that clicking a button on my web page triggers the correct action?
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.