Skip to content

feat(runtime): implement jstz_test ext#1378

Open
johnyob wants to merge 1 commit intomainfrom
ajob410@jstz-test-ext
Open

feat(runtime): implement jstz_test ext#1378
johnyob wants to merge 1 commit intomainfrom
ajob410@jstz-test-ext

Conversation

@johnyob
Copy link
Collaborator

@johnyob johnyob commented Nov 12, 2025

Context

This PR implements functionality in the Jstz runtime to add support for registering test specifications.

The API is identical to Deno.test (https://docs.deno.com/runtime/fundamentals/testing/)

Description

This PR copies and pastes code directly from https://github.com/denoland/deno/tree/main/cli/tools/test
and https://github.com/denoland/deno/tree/main/cli/js.

When reviewing this PR, one can ignore:

Most of the types and functions in jstz_test/mod.rs are taken from various files in https://github.com/denoland/deno/tree/main/cli/tools/test.

Manually testing the PR

This PR comes with a unit test to check that we correctly register the extension and that test specs are visible in Rust once the main module has been evaluated.

cargo test --package jstz_runtime --lib --features v2_runtime -- ext::jstz_test::tests

@johnyob johnyob force-pushed the ajob410@jstz-test-ext branch from a741ffb to 4ff5878 Compare November 19, 2025 16:01
@johnyob johnyob changed the title feat(runtime, cli): add support for unit testing smart functions feat(runtime): implement jstz_test ext Nov 19, 2025
@johnyob johnyob force-pushed the ajob410@jstz-test-ext branch from 4ff5878 to c9bf455 Compare November 19, 2025 16:09
@johnyob johnyob force-pushed the ajob410@jstz-test-ext branch from c9bf455 to a2c945d Compare November 19, 2025 16:29
@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

❌ Patch coverage is 34.90909% with 179 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.93%. Comparing base (dc6aab6) to head (a2c945d).

Files with missing lines Patch % Lines
crates/jstz_runtime/src/ext/jstz_test/mod.rs 34.90% 179 Missing ⚠️
Files with missing lines Coverage Δ
crates/jstz_runtime/src/ext/mod.rs 0.00% <ø> (ø)
crates/jstz_runtime/src/lib.rs 16.66% <ø> (ø)
crates/jstz_runtime/src/ext/jstz_test/mod.rs 34.90% <34.90%> (ø)

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dc6aab6...a2c945d. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +4 to +6

pub mod jstz_test;

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
pub mod jstz_test;
pub mod jstz_test;

Can we remove the empty lines?

Copy link
Collaborator

@zcabter zcabter Dec 2, 2025

Choose a reason for hiding this comment

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

Do these js files have accompanying .d.ts files?

@zcabter zcabter assigned johnyob and unassigned zcabter Dec 2, 2025
@zcabter
Copy link
Collaborator

zcabter commented Dec 2, 2025

Could you also create Linear issues and attach them to Jstz.Test framework for project level tracking?

Comment on lines +577 to +579
// The runtime must be explicitly dropped to avoid an assert false
// in `InnerIsolateState::prepare_for_cleanup`.
drop(runtime);
Copy link
Collaborator

Choose a reason for hiding this comment

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

That's odd... Doesn't JstzRuntime automatically drop when it goes out of scope on line 582?

Plan(TestPlan),
Wait(usize),
Output(Vec<u8>),
Slow(usize, u64),
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does this do?

@@ -0,0 +1,606 @@
// Copyright 2018-2025 the Deno authors. MIT license.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Its probably a good idea to document the general ADT architecture either on top of each struct or as an overview here for future maintainers to get a better mental model of the data structure

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