vscode-tmgrammar-test is a utility for testing VSCode TextMate grammars using a user-friendly plaintext file format, inspired by Sublime Text's syntax testing capabilities. The package provides both unit and snapshot testing functionalities, allowing developers to verify syntax highlighting behavior against a VSCode engine. The current stable version is v0.1.3, with releases occurring periodically to introduce new features, fix bugs, and address breaking changes, such as the removal of certain CLI options and dropping Node.js 10.x support in v0.1.1. Key differentiators include its direct use of the VSCode TextMate engine for accurate simulation, a clear and concise assertion syntax within test files for precise scope checking, and built-in snapshot testing for tracking grammar changes over time. It is designed to be integrated as a development dependency, primarily invoked via its command-line interface, making it an essential tool for grammar authors.
npm install vscode-tmgrammar-testVerified import paths — ran on the pinned version, not inferred.
Demonstrates installation as a dev dependency and running a basic unit test for a TextMate grammar using the CLI tool.
Remove the `-t` option and pass test file paths directly, e.g., `vscode-tmgrammar-test 'path/to/tests/**/*.scala'`.
Remove the `--scope` option. Ensure unit test headers correctly specify the language scope, e.g., `// SYNTAX TEST "source.scala"`.
Remove any usage of the `--validate` option from your CLI commands.
Upgrade your Node.js environment to a supported version (e.g., Node.js 12 or newer).
If encountering unexpected behavior with Unicode, re-evaluate test cases, especially those with complex regex patterns involving Unicode characters, and ensure they align with the updated VSCode/Oniguruma behavior.
Update `vscode-tmgrammar-test` to v0.0.11 or newer to fix the issue with updated `vscode-textmate` and `oniguruma` which resolves certain invalid pattern errors.
Update `vscode-tmgrammar-test` to v0.0.7 or newer. This version introduced logic to handle both Windows and Unix line endings consistently across platforms.
Update `vscode-tmgrammar-test` to v0.0.6 or newer. This version includes specific fixes to ensure test cases run correctly on Windows operating systems.