2023-11-15


Vitest - pass props to render
It’s possible to pass props to render if the component you’re testing needs them.
const { container } = render(Layout, {
  props: {
    data,
  },
});
In this case I’m passing load function data to my layout route.
Vitest - test load function data
It’s possible to test a load function to Vitest in case you want to have an integration test for your server/data.
Simply import load (named) from the file and then do  const data = await load({ fetch }) and you’ll be able to test the data.
Go back to all posts

2023-10-15


Test snapshots should be in alphabetical order
I submitted a PR and was surprised (not really) when CI failed, it turns out snapshots should be in alphabetical order.
…makes sense!
I also learned that you shouldn’t really type the snapshots by hand, it’s easier to add a test, run it, see what comes in (vs what the snapshot was before), if it was the correct thing just copy paste the snapshot. And place it in alphabetical order. 😊
Go back to all posts