Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a Unit-Testing Story #489

Closed
eiswind opened this issue Feb 7, 2023 · 2 comments
Closed

Is there a Unit-Testing Story #489

eiswind opened this issue Feb 7, 2023 · 2 comments
Labels
question Further information is requested

Comments

@eiswind
Copy link
Contributor

eiswind commented Feb 7, 2023

Do you have any plans on supporting unit-tests for components?
None of the current Rust Web-Frameworks I have seen has this, it a pity.

@gbj gbj added the question Further information is requested label Feb 7, 2023
@gbj
Copy link
Collaborator

gbj commented Feb 7, 2023

The end-to-end testing story is pretty good, using wasm-pack test (which as I understand it is now incorporated into cargo test --target=wasm32-unknown-unknown) which uses a headless browser. You can see an example of integration tests for a Leptos app in our counters example (in the tests directory). (cargo-leptos also comes with built in e2e testing via Playwright, although I haven't explored it too much.)

Unit tests for components in any browser-based framework are quite hard, because it usually means spinning up a headless browser or using something like JSDOM which doesn't necessarily precisely emulate real browsers anyway.

Take a look at the example of testing for the counter app. If there are specific improvements you think could be made to how we're enabling testing, let me know!

@gbj gbj mentioned this issue Feb 11, 2023
22 tasks
gbj added a commit that referenced this issue Feb 12, 2023
@gbj gbj closed this as completed in db3f46c Feb 12, 2023
@eiswind
Copy link
Contributor Author

eiswind commented Feb 13, 2023

The new docs look great!

fundon added a commit to fundon/leptos that referenced this issue Feb 14, 2023
* main:
  Reexport `web-sys` event types in `leptos::ev` to make it easier to type handlers (leptos-rs#521)
  fix: correct namespace for `Unit` in empty views (closes leptos-rs#518) (leptos-rs#520)
  leptos_dom erros.rs remove<E>() does not need to be generic. (leptos-rs#516)
  `0.2.0-alpha` (leptos-rs#515)
  remove `.unwrap()` from `redirect` in Actix integration (leptos-rs#514)
  do not unwrap use_context in integrations axum redirect (leptos-rs#513)
  CI: fix Wasm testing (leptos-rs#511)
  fix: SSR export in Wasm mode (leptos-rs#512)
  fix: import in `leptos_dom` and add Wasm build to CI for regressions (leptos-rs#510)
  Typos and a small cleanup (leptos-rs#509)
  change: reorganize module exports and reexports (leptos-rs#503)
  Add docs on testing (closes leptos-rs#489) (leptos-rs#508)
gbj added a commit that referenced this issue Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants