Skip to content

Add test suite package#413

Open
dgtlntv wants to merge 3 commits into
design-tokens:mainfrom
dgtlntv:pr/02-test-suite
Open

Add test suite package#413
dgtlntv wants to merge 3 commits into
design-tokens:mainfrom
dgtlntv:pr/02-test-suite

Conversation

@dgtlntv

@dgtlntv dgtlntv commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

(This PR is stacked on top of #412. So the diff also includes the schema package changes from that PR. The new changes in this PR are focused on the test suite package and the schema tests that consume it.)

Changes

This PR introduces a test suite as a separate package. I originally created these fixtures to test the JSON schema while working on it, but I think they may also be useful to third-party design token tool developers. At the moment, every design token tool developer has to write their own fixtures to test things like token parsers. Being able to use official fixtures could make that easier.

For the DTCG, this gives the fixtures a dual purpose: they let us test the JSON schemas we publish, and they provide official test fixtures for the wider community.

This PR also adds tests to the schemas package that use the fixtures to test the bundled schemas. These tests currently run with ajv. I also added a vscode-json-languageservice test setup so we can verify that the JSON schemas work in VS Code as well. Those tests are currently skipped because they do not pass yet. We need to wait for the upstream fix mentioned in #412.
The test setup is structured so it should be easy to add more JSON schema validators in the future if we want to compare behavior across multiple validators.

The test suite package itself is structured similarly to the JSON-LD Working Group test suites. Specifically it uses manifest files instead of relying only on folder structure, so each fixture has an explicit id, expected result, purpose, input path, and feature tags. That should make the fixtures easier to consume programmatically, easier to review, and easier to extend over time without forcing every implementation to infer test meaning from filenames alone.

I know this PR is quite big and probably hard to review. LMK if I should split it up in a certain way.

How to Review

  • Run the tests in the schemas package and make sure they pass.
  • Look at the test fixtures and make sure they make sense.

@netlify

netlify Bot commented Jun 3, 2026

Copy link
Copy Markdown

Deploy Preview for designtokensorg ready!

Name Link
🔨 Latest commit 658faf9
🔍 Latest deploy log https://app.netlify.com/projects/designtokensorg/deploys/6a33b5e12ce9030008354bf4
😎 Deploy Preview https://deploy-preview-413--designtokensorg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@dgtlntv

dgtlntv commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

This would fix issue #386

@drwpow drwpow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look great! And I see that the pnpm --recursive run test already picked up the new tests with the "test" npm script. I’ll wait for this to rebased off main, but otherwise LGTM and can’t wait to ship!

@@ -0,0 +1,105 @@
/**
* Schema validation tests using the VS Code JSON language service.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯💯💯 I can’t believe we’ll get these (well, once the issue mentioned is fixed upstream)!!

Comment thread schemas/tests/helpers.ts Outdated
errorDetails: string;
}

/** Options for customising test generation. */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use US English "customizing" (and then remove "customising" from terminology.txt)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! :)

dgtlntv and others added 2 commits June 18, 2026 11:02
Introduce the test-suite package with positive and negative
test fixtures for format and resolver schemas, and add
AJV-based and VS Code validation tests to the schemas package.

- Add test-suite package with 250 test fixtures organized by
  token type (colors, dimensions, borders, typography, etc.)
- Add schema validation tests using AJV (vitest)
- Add VS Code JSON language service tests (currently skipped
  pending upstream fix for $id-based $ref resolution)
- Add test dependencies to schemas package (ajv, vitest, etc.)
- Add test-suite to pnpm workspace
- Add build:schemas step to CI workflow (required before tests)
@dgtlntv dgtlntv force-pushed the pr/02-test-suite branch from 14b10a2 to 2f3e66a Compare June 18, 2026 09:05
@dgtlntv

dgtlntv commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

These look great! And I see that the pnpm --recursive run test already picked up the new tests with the "test" npm script. I’ll wait for this to rebased off main, but otherwise LGTM and can’t wait to ship!

Rebased it and addressed @kaelig feedback as well!

Once the fix lands for the VSCode JSON language service I would create a followup PR that un-skips the VSCode tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants