italojsmeteor:node-test-runner

v0.0.3Published 3 days ago

italojs:node-test-runner

Test-only Meteor driver that runs server and client suites with the Node.js native test runner (no fibers), reusing the headless plumbing from meteortesting:browser-tests.

What it is

  • Exposes test/describe/before/after/beforeEach/afterEach globally on server and client.
  • Runs server suites in Node and client suites in a headless browser driver (e.g., puppeteer) with a shared summary and exit code.
  • Meteor versions: tested with Meteor 3.3.2; api.versionsFrom(['3.0']).

Quick start (as a local package)

From your Meteor app:

# point to the folder that contains meteor-node-test-runner/
export METEOR_PACKAGE_DIRS=/path/to/parent

# full run (server + client, headless)
TEST_BROWSER_DRIVER=puppeteer meteor test --once --driver-package italojs:node-test-runner

# server only
TEST_CLIENT=0 meteor test --once --driver-package italojs:node-test-runner

# client only (needs browser driver)
TEST_SERVER=0 TEST_BROWSER_DRIVER=puppeteer meteor test --once --driver-package italojs:node-test-runner

Environment variables (parsed in runtimeArgs.js)

  • METEOR_PACKAGE_DIRS: path to this package when used locally.
  • TEST_BROWSER_DRIVER: driver name for meteortesting:browser-tests (required for client tests).
  • TEST_CLIENT / TEST_SERVER (default: true): enable/disable each side.
  • TEST_PARALLEL: run server and client concurrently.
  • TEST_WATCH or METEOR_AUTO_RESTART=true: keep the process alive instead of exiting after a run.
  • NODE_TEST_PATTERN or MOCHA_GREP: regex to filter full test names.
  • NODE_TEST_INVERT or MOCHA_INVERT: invert the filter above.
  • NODE_TEST_TIMEOUT: per-test/hook timeout (ms).
  • NODE_TEST_CONCURRENCY: accepted but not yet applied (execution is sequential).
  • CLIENT_TESTS_TIMEOUT_MS: max wait for the browser driver to report completion (ms, default 120000).

How it works

  • Server (server.js + server-runner.js)
    • Injects the test API into globalThis.
    • Runs suites, prints pass/fail/skip/todo and duration, exits with combined failures (unless watch mode).
    • Listens to client-refresh and webapp-reload-client to re-run client suites after hot reloads.
  • Client (client.js + client-runner.js)
    • Recomputes runtime args in the browser (or uses Meteor.settings.public.nodeNativeTestRuntime).
    • Provides the same global API and records uncaught errors/unhandled rejections as failures.
    • Uses startBrowser from meteortesting:browser-tests to drive headless execution.

Known limitations

  • Sequential execution; NODE_TEST_CONCURRENCY is not implemented yet.
  • Console-only reporter; no TAP/JUnit or coverage integration.
  • Running with TEST_PARALLEL=1 can cause shared DB/state side effects.

Folder contents

  • package.js — Meteor package definition.
  • server.js / client.js — bootstraps and bridges to the runners.
  • server-runner.js / client-runner.js — minimal Node test runner implementations for each side.
  • runtimeArgs.js — parses env vars and shares them via Meteor.settings.public.