This package provides a comprehensive test runner for validating TextMate grammars against the same engine used by VS Code. It offers both unit and snapshot testing capabilities, enabling developers to write assertions against token scopes and to easily track changes in grammar tokenization over time. The current stable version is 0.6.0, with minor releases occurring relatively frequently, driven by performance improvements, bug fixes, and feature enhancements. It serves as a modern and actively maintained successor to the `vscode-tmgrammar-test` package, featuring an updated codebase and enhanced functionality. Key differentiators include its direct validation against the VS Code TextMate engine, robust snapshot testing with an update mechanism, and detailed unit testing syntax for precise scope assertions, including negative assertions and line start token targeting.
npm install textmate-grammar-testVerified import paths — ran on the pinned version, not inferred.
Demonstrates setting up `textmate-grammar-test` in `package.json` scripts and a basic unit test file for a TypeScript grammar.
Migrate to alternative reporting mechanisms or update CI configurations to no longer expect XUnit output from `textmate-grammar-test`.
Ensure you are on version 0.4.2 or later if you intend to use the `--scope` option. Always refer to the `--help` output for the most current options.
After installing `textmate-grammar-test` and updating package references, run `npx textmate-grammar-snap --updateSnapshot "tests/**/*.foo"` once to conform to the new snapshot format.
Ensure all unit test `.ts` or `.js` files use spaces for indentation. Configure your editor to convert tabs to spaces for these files.
Migrate to `textmate-grammar-test` by installing `npm i -D textmate-grammar-test` and replacing all occurrences of `vscode-tmgrammar-test` and `vscode-tmgrammar-snap` in your project.
Ensure `textmate-grammar-test` is listed in your `devDependencies` and run the command using `npx textmate-grammar-test` (e.g., `npx textmate-grammar-test syntax/tests/**/*.ts`) or add it to your `PATH` if globally installed (less common for dev tools).
If the changes are expected, update your snapshots by running `npx textmate-grammar-snap --updateSnapshot "tests/**/*.foo"`. If not, review your grammar changes or test files.
Convert all tab characters to spaces within the affected unit test file(s). Most IDEs have a 'Convert Indentation to Spaces' feature.
Ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json`) if using `import`, or install the package with `npm install textmate-grammar-test`.
No dependency data recorded yet.