Skip to content

uhop/tape-six-playwright

Repository files navigation

tape-six-playwright NPM version

tape-six-playwright is a helper for tape-six to run tests in a headless browser via Playwright. Each test file runs in its own iframe inside headless Chromium, providing full browser isolation.

Why?

The standard tape6 runner uses worker threads. tape6-playwright launches headless Chromium and runs each test file in a separate iframe, giving tests access to real DOM, browser APIs, and the full web platform. Tests can be .js/.mjs modules or .html files.

Install

npm i -D tape-six-playwright

Playwright's bundled Chromium is installed automatically via postinstall.

Quick start

  1. Write tests using tape-six that use browser APIs:
import test from 'tape-six';

test('DOM works', t => {
  const el = document.createElement('div');
  el.textContent = 'hello';
  document.body.appendChild(el);
  t.equal(document.body.lastChild.textContent, 'hello', 'element created');
});
  1. Configure tests in package.json:
{
  "scripts": {
    "test": "tape6-playwright --start-server --flags FO"
  },
  "tape6": {
    "browser": ["/tests/test-*.html"],
    "tests": ["/tests/test-*.*js"],
    "importmap": {
      "imports": {
        "tape-six": "/node_modules/tape-six/index.js",
        "tape-six/": "/node_modules/tape-six/src/"
      }
    }
  }
}
  1. Run:
npm test

Server

tape6-playwright requires tape6-server (from tape-six) to serve test files to the browser.

  • Auto-start: use --start-server to launch it automatically.
  • Manual: run npx tape6-server in a separate terminal, then run tests without --start-server.
  • Custom URL: use --server-url URL (-u), or set TAPE6_SERVER_URL or HOST/PORT environment variables.

Cross-runtime usage

{
  "scripts": {
    "test": "tape6-playwright --start-server --flags FO",
    "test:bun": "bun run `tape6-playwright --self` --start-server --flags FO",
    "test:deno": "deno run -A `tape6-playwright --self` --start-server --flags FO"
  }
}

Docs

See the wiki for full documentation. tape-six has its own wiki.

tape-six-playwright uses the same test configuration and CLI conventions as tape-six.

Command-line utilities

AI agents

If you are an AI coding agent, see AGENTS.md for project conventions, commands, and architecture.

LLM-friendly documentation is available:

Release notes

The most recent releases:

  • 1.0.3 Replaced process.exit() with process.exitCode to prevent truncated output.
  • 1.0.2 Added --help/-h and --version/-v CLI options.
  • 1.0.1 Updated dependencies, added npm run browser script, improved workflows.
  • 1.0.0 The first official release.

See the full release notes for details.

About

Playwright-based browser test runner for tape-six. Runs each test file in its own iframe inside headless Chromium. Works with Node, Deno, and Bun.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors