@ 261022.1raw
current

Source Map Tests

This repository holds discussions on testing and tests for the Source Map debugging format. Specifically, we’re looking to encourage discussion around:

Open discussion happens in the GitHub issues.

Source Map spec:

Test cases

This repo also contains cross-implementation test cases that can be run in test suites for source map implementations, including browser devtool and library test suites.

Running the tests

Tools

Source map validatorgithub:

Browsers

The tests for Firefox are in the Mozilla source-mapgithub library:

How to run in WebKit:

How to run in Chrome Devtools:

  1. Setup:
    • Install depot_tools following this depot_tools guide
    • Check out Chrome Devtools:
    • Run gclient config https://chromium.googlesource.com/devtools/devtools-frontend --unmanaged
    • Run cd devtools-frontend
    • Run gclient sync
    • Run gn gen out/Default
  2. Build:
    • Run autoninja -C out/Default
  3. Test:
    • Run npm run auto-unittest
  4. Apply patches from this repo:
    • Run git apply <path to .patch file> in devtools-frontend repo

More information about running Chrome Devtools without building Chromium can be found here

Node.js

Follow the running Node.js tests guidegithub to build Node.js and run tests locally. Read more about running the source map tests at heregithub.

npm package

The test cases are published to npm as @tc39/source-map-tests, so that source map implementations can run them in their own test suites. A new version is published for every commit to main.

npm install --save-dev --save-exact @tc39/source-map-tests

Usage

@tc39/source-map-tests/suites.json lists the test suites:

{
  "suites": [
    { "kind": "interpreting", "file": "interpreting/source-map-spec.json" },
    { "kind": "decoding", "file": "decoding/scopes.json" }
  ]
}

There are two types of test suites: interpreting and decoding:

TypeScript

The package’s root exports the types of the JSON files:

import type { InterpretingSuite, DecodingSuite, TestAction } from "@tc39/source-map-tests";

With TypeScript 7.1 or later, you can load type definitions for the various suites by adding "types": ["@tc39/source-map-tests"] to your tsconfig.json. Imported JSON modules then will be typed appropriately:

import spec from "@tc39/source-map-tests/interpreting/source-map-spec.json" with { type: "json" };
spec.tests[0].testActions; // TestAction[]