Skip to content

Testing pages with layout dependencies. #426

Answered by mcous
niemyjski asked this question in Q&A

You must be logged in to vote

@niemyjski this is a very good question! Thanks for taking the time to post it.

I lead a team maintaining a large SvelteKit app that uses svelte-query for its client-side API state management. This is a recommendation from me personally rather than anything "official," but I've found the best1 strategy for component tests is pretty classic Uncle Bob: separate the stuff you want to test away from the framework glue. In practice, this means:

  • No component-level tests for +page.svelte/+layout.svelte
  • No component-level tests for anything that wires into createQuery, createMutation, etc.
  • No/few component-level tests for components that subscribe to context
    • Sometimes, especially if its a conte…

Replies: 1 comment 1 reply

You must be logged in to vote
1 reply
@niemyjski

Answer selected by niemyjski
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #425 on February 26, 2025 22:29.