tito10047/asset-mapper-test-bundle

A Symfony bundle that bridges the gap between Symfony AssetMapper and Node.js test runners by creating a symlink-based node_modules structure from your import map.

Maintainers

Package info

github.com/tito10047/asset-mapper-test-bundle

Type:symfony-bundle

pkg:composer/tito10047/asset-mapper-test-bundle

Statistics

Installs: 9

Dependents: 0

Suggesters: 0

Stars: 2

Open Issues: 0

0.2.0 2026-04-22 15:02 UTC

This package is auto-updated.

Last update: 2026-04-22 15:04:22 UTC


README

CI License

Run Node.js tests against packages managed by Symfony AssetMapper — no npm install, no duplicated dependencies.

Two interchangeable strategies are provided:

Strategy Command How it works
Symlinks (default) php bin/console asset-mapper-test:setup Creates symlinks in node_modules/ from importmap.php
Symlink-free loader php bin/console asset-mapper-test:export Exports importmap.json, a Node.js loader maps imports live

Pick symlinks for best IDE autocomplete. Pick the loader when you want zero node_modules, cross-platform cleanliness (Windows without developer mode), or reproducible CI without filesystem artifacts.

Install

composer require --dev tito10047/asset-mapper-test-bundle

Auto-discovered by Symfony Flex — no additional wiring needed.

Scaffold package.json (interactive)

php bin/console asset-mapper-test:init

Asks which variant (symlink / loader) and which JS runner (node / vitest) you want, then writes a matching package.json. For node --test it also drops tests/js/setup.mjs with a ready-to-use happy-dom window bootstrap (globalThis.window, document, HTMLElement, Event).

Non-interactive (CI) form:

php bin/console asset-mapper-test:init --variant=loader --runner=node

Quick start — Symlink variant

{
  "type": "module",
  "scripts": {
    "pretest": "php bin/console asset-mapper-test:setup",
    "test":    "node --import ./tests/js/setup.mjs --test 'tests/js/**/*.test.mjs'"
  }
}
npm test

Quick start — Loader variant (no node_modules)

{
  "type": "module",
  "scripts": {
    "pretest": "php bin/console asset-mapper-test:export",
    "test":    "node --import ./vendor/tito10047/asset-mapper-test-bundle/src/Resources/loader/register.mjs --import ./tests/js/setup.mjs --test 'tests/js/**/*.test.mjs'"
  }
}

Requires Node.js ≥ 20.6 (or ≥ 18.19) for the stable module.register API.

Documentation

Full documentation lives in docs/:

Requirements

  • PHP ≥ 8.2
  • Symfony ≥ 6.4 (also works on 7.x and 8.x)
  • Symfony AssetMapper
  • Node.js ≥ 20.6 for the loader variant (any version for symlinks)

License

MIT — see LICENSE.