Skip to content

test: Add support for Typescript tests in core - #10375

Merged
gonfunko merged 3 commits into
mainfrom
ts-tests
Aug 27, 2026
Merged

test: Add support for Typescript tests in core#10375
gonfunko merged 3 commits into
mainfrom
ts-tests

Conversation

@gonfunko

Copy link
Copy Markdown
Contributor

The basics

The details

Proposed Changes

This PR adds support for writing tests for core Blockly in Typescript, and converts some of the existing tests that are trivially convertible. It also resolves a few bugs related to calling new on non-constructors in the JS tests that TSC surfaced.

Once this is merged, we can and should begin gradually converting the remainder of the test suite to Typescript, and use Typescript for all newly-introduced test files. A few notes regarding best practices:

  • Typescript tests should not stick things onto this to share state between setup and tests. Instead, they should declare variables at the top-level suite, assign them in setup, and reference them in tests. This ensures that everything typechecks; lint will yell at you if you try to tack things on to this.
  • Relatedly, TS tests must pass the workspace under test to sharedTestTeardown()
  • TS tests must always import * as Blockly from '#core/blockly.js'; as well as importing sinon and chai where needed. If a TS test exercises something that is not exported from core, they may import it by path relative to #core. In general, this pattern should address Use Blockly consistently in mocha tests #7224 once the entire suite is converted – always import and use Blockly, unless testing something that isn't exported, in which case import it directly.

Reason for Changes

Better typechecking catches bugs and forces us to be less sloppy in our tests.

@gonfunko
gonfunko requested a review from a team as a code owner August 27, 2026 18:41
@gonfunko
gonfunko requested a review from lizschwab August 27, 2026 18:41
@gonfunko
gonfunko merged commit bd29b09 into main Aug 27, 2026
11 checks passed
@gonfunko
gonfunko deleted the ts-tests branch August 27, 2026 20:52
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.

2 participants