Skip to content

bug: Vitest suite crashes on Windows due to invalid path backslashes #1730

Description

@ApurveKaranwal

I encountered an issue running the meta-schema tests on a Windows environment. Running npm test fails immediately on all 7 test cases with Error: Invalid IRI-reference.

Root Cause

The path resolution in specs/meta/test-suite/meta-schema.test.js resolves the meta-schema path using a string template:

`${import.meta.dirname}/../meta.schema.json`

On Windows, this resolves with backslashes (e.g., D:\path\to\specs\meta\test-suite/../meta.schema.json). Because the internally used @hyperjump/uri library strictly validates references against RFC 3986 (where backslashes are illegal URI characters), the parser throws an exception and crashes the test run.

Steps to Reproduce

  1. Clone the repository on Windows.
  2. Run npm install and npm test.
  3. The test execution fails with the following traceback:
Error: Invalid IRI-reference: D:\VS Code Projects\OSS\json-schema-spec\specs\meta\test-suite/../meta.schema.json
 ❯ Object.parseReference node_modules/@hyperjump/uri/lib/index.js:225:11
 ❯ node_modules/@hyperjump/uri/lib/index.js:83:78
 ❯ getSchema node_modules/@hyperjump/json-schema/lib/schema.js:33:24

Screenshot:

Image

Proposed Solution

To ensure cross-platform compatibility, we can resolve the file path as a standard file URL:

const metaSchemaUrl = new URL("../meta.schema.json", import.meta.url).href;

I have verified this fix locally on Windows and all tests pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions