Skip to content

feat: add SSR e2e hydration tests for simple_ssr and ssr_router#4046

Merged
Madoshakalaka merged 5 commits intomasterfrom
e2e
Mar 6, 2026
Merged

feat: add SSR e2e hydration tests for simple_ssr and ssr_router#4046
Madoshakalaka merged 5 commits intomasterfrom
e2e

Conversation

@Madoshakalaka
Copy link
Member

@Madoshakalaka Madoshakalaka commented Mar 5, 2026

Adds end-to-end hydration tests for SSR examples (simple_ssr, ssr_router) using wasm-bindgen-test as the browser test runner. This is a pure-Rust E2E testing approach that requires no non-Rust dependencies like Playwright, Cypress, or Selenium.

(There were a lot of past discussion on e2e frameworks. My impression was that maintainers generally didn't want to introduce them. e.g. @its-the-shrimp was against introducing more javascript deps, @futursolo slightly favored playwright but was also slightly reluctant on introducing it)

closes #196 (open since 2018).

New crates

  • tools/ssr-e2e -- test orchestrator that runs trunk build, starts the SSR server, waits for it to become healthy, runs cargo test (wasm-bindgen-test) against the server, and tears everything down.
  • tools/ssr-e2e-harness -- shared wasm32 library providing test utilities: fetching SSR HTML, injecting it into the wasm-bindgen-test output element, polling helpers, History API push.

Other changes

  • CORS headers added to simple_ssr (warp) and ssr_router (axum) servers so cross-origin fetches from the wasm-bindgen-test browser context succeed.
  • wasm-bindgen-test added to workspace dependencies.
  • CI job ssr_e2e_tests added to main-checks.yml with a matrix over both examples.

(Not) The only gap

One gap compared to a full E2E framework is screenshot/visual regression testing, which is being addressed upstream in wasm-bindgen#5014.

@Madoshakalaka
Copy link
Member Author

@WorldSEnder 🫣

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

Size Comparison

Details
examples master (KB) pull request (KB) diff (KB) diff (%)
async_clock 100.272 100.272 0 0.000%
boids 168.099 168.099 0 0.000%
communication_child_to_parent 93.485 93.485 0 0.000%
communication_grandchild_with_grandparent 105.262 105.262 0 0.000%
communication_grandparent_to_grandchild 101.610 101.610 0 0.000%
communication_parent_to_child 90.899 90.899 0 0.000%
contexts 105.177 105.177 0 0.000%
counter 86.282 86.282 0 0.000%
counter_functional 88.276 88.276 0 0.000%
dyn_create_destroy_apps 90.322 90.322 0 0.000%
file_upload 99.377 99.377 0 0.000%
function_delayed_input 94.377 94.377 0 0.000%
function_memory_game 172.944 172.944 0 0.000%
function_router 406.599 406.599 0 0.000%
function_todomvc 164.163 164.163 0 0.000%
futures 235.191 235.191 0 0.000%
game_of_life 104.732 104.732 0 0.000%
immutable 255.891 255.891 0 0.000%
inner_html 80.803 80.803 0 0.000%
js_callback 109.401 109.401 0 0.000%
keyed_list 179.740 179.740 0 0.000%
mount_point 84.174 84.174 0 0.000%
nested_list 113.072 113.072 0 0.000%
node_refs 91.523 91.523 0 0.000%
password_strength 1729.185 1729.185 0 0.000%
portals 93.034 93.034 0 0.000%
router 377.158 377.158 0 0.000%
suspense 113.502 113.502 0 0.000%
timer 88.641 88.641 0 0.000%
timer_functional 98.881 98.881 0 0.000%
todomvc 142.114 142.114 0 0.000%
two_apps 86.176 86.176 0 0.000%
web_worker_fib 136.155 136.155 0 0.000%
web_worker_prime 187.383 187.383 0 0.000%
webgl 83.224 83.224 0 0.000%

✅ None of the examples has changed their size significantly.

@github-actions
Copy link

github-actions bot commented Mar 6, 2026

Benchmark - core

Yew Master

vnode           fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ vnode_clone  2.049 ns      │ 2.141 ns      │ 2.053 ns      │ 2.056 ns      │ 100     │ 1000000000

Pull Request

vnode           fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ vnode_clone  2.092 ns      │ 3.341 ns      │ 2.093 ns      │ 2.134 ns      │ 100     │ 1000000000

@github-actions
Copy link

github-actions bot commented Mar 6, 2026

Visit the preview URL for this PR (updated for commit 3088482):

https://yew-rs-api--pr4046-e2e-ay5tps8a.web.app

(expires Fri, 13 Mar 2026 16:23:05 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

@github-actions
Copy link

github-actions bot commented Mar 6, 2026

Benchmark - SSR

Yew Master

Details
Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 310.817 311.235 310.989 0.144
Hello World 10 481.526 507.111 496.064 9.885
Function Router 10 32246.059 33884.297 33280.110 490.276
Concurrent Task 10 1005.986 1007.628 1006.881 0.594
Many Providers 10 1099.546 1180.333 1129.062 29.792

Pull Request

Details
Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 310.796 311.375 310.947 0.174
Hello World 10 490.376 511.084 496.255 5.968
Function Router 10 33625.284 34657.394 34126.774 321.626
Concurrent Task 10 1005.733 1007.575 1006.833 0.590
Many Providers 10 1092.498 1133.747 1115.763 16.327

@Madoshakalaka
Copy link
Member Author

I think the CI failure is caused by the stablization of the include config key with rust 1.94 today. Addressing in a different PR

Introduces ssr-e2e orchestrator (trunk build, server start, wasm-bindgen-test
runner) and ssr-e2e-harness (shared wasm32 test utilities). Adds e2e tests that
fetch SSR-rendered HTML, inject it into the wasm-bindgen-test output element,
and hydrate against it to verify no hydration panics. Also adds CORS support
to both SSR servers for cross-origin test fetches and a CI workflow job.
@Madoshakalaka Madoshakalaka marked this pull request as ready for review March 6, 2026 16:41
github-actions[bot]
github-actions bot previously approved these changes Mar 6, 2026
WorldSEnder
WorldSEnder previously approved these changes Mar 6, 2026
Comment on lines +95 to +97
unsafe {
libc::kill(-(id as i32), libc::SIGTERM);
}
Copy link
Member

Choose a reason for hiding this comment

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

Two small comments here:

  • Ignores the return value without being explicit about as below
  • Technically this races for the pid. The server could exit (crash?) and get replaced by a different process with the same process id which would get the axe. Avoidable only with nightly API though and unlikely to happen since the server is supposed to keep running.

Copy link
Member Author

Choose a reason for hiding this comment

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

good point. made the first return explicit.

@WorldSEnder WorldSEnder mentioned this pull request Mar 6, 2026
2 tasks
@Madoshakalaka Madoshakalaka merged commit 14a4c18 into master Mar 6, 2026
29 checks passed
@Madoshakalaka Madoshakalaka deleted the e2e branch March 6, 2026 17:46
@Madoshakalaka Madoshakalaka added A-ci Area: The continuous integration A-tools Area: Tools such as trunk, wasm-bindgen labels Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ci Area: The continuous integration A-tools Area: Tools such as trunk, wasm-bindgen

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Develop E2E Tests

2 participants