Testing
Testing patterns for peace of mind![Ian Macartney's Profile image](/_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fts10onj4%2Fproduction%2F077753b63476b77fb111ba06d1bb538517033a54-3500x3500.jpg&w=3840&q=75)
Learn about best practices for testing your full-stack apps - running on Convex or elsewhere!
![Ian Macartney's Profile image](/_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fts10onj4%2Fproduction%2F077753b63476b77fb111ba06d1bb538517033a54-3500x3500.jpg&w=3840&q=75)
Ian Macartney
4 months ago
Running tests using a local open-source backend![Sarah Shader's Profile image](/_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fts10onj4%2Fproduction%2F7047febd1fcf4e4b44d4da9f199c07d842acf23b-1365x1418.jpg&w=3840&q=75)
Convex recently released an open source version of the backend. We can use this to unit test Convex functions by running them with a local backend. These tests will work by running a backend locally, pushing your code, and using the `ConvexClient` to execute queries and mutations from your favorite testing framework and asserting on the results.
![Sarah Shader's Profile image](/_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fts10onj4%2Fproduction%2F7047febd1fcf4e4b44d4da9f199c07d842acf23b-1365x1418.jpg&w=3840&q=75)
Sarah Shader
4 months ago
Seeding Data for Preview Deployments![Ian Macartney's Profile image](/_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fts10onj4%2Fproduction%2F077753b63476b77fb111ba06d1bb538517033a54-3500x3500.jpg&w=3840&q=75)
Now that we've launched Preview Deployments on Convex, you can test out backend changes easier than ever. But you may want to seed your project with data first, so let's go over how to do that.
![Ian Macartney's Profile image](/_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fts10onj4%2Fproduction%2F077753b63476b77fb111ba06d1bb538517033a54-3500x3500.jpg&w=3840&q=75)
Ian Macartney
9 months ago
Testing Your App: How to Generate Fake Data![Nicolas Ettlin's Profile image](/_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fts10onj4%2Fproduction%2F1ac93a575829f65dcb9deec8565971180ec23b1b-306x306.jpg&w=3840&q=75)
Learn how to generate fake data for your dev deployments using the Faker library
![Nicolas Ettlin's Profile image](/_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fts10onj4%2Fproduction%2F1ac93a575829f65dcb9deec8565971180ec23b1b-306x306.jpg&w=3840&q=75)
Nicolas Ettlin
a year ago
Testing React Components with Convex![Arnold Trakhtenberg's Profile image](/_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fts10onj4%2Fproduction%2F4f15f1b5bf88a631070c66706bd5b819ff6fd2d1-852x852.jpg&w=3840&q=75)
Oftentimes during testing we want to mock out our backend so we can unit test our UI components without talking to our actual server code.
In this article, we’ll explore options for testing React components that call Convex React hooks using mocking and dependency injection. To do this, I’ve written a sample TypeScript React app using the Vitest testing framework. The patterns presented in this post are also applicable to other JavaScript apps and frameworks.
![Arnold Trakhtenberg's Profile image](/_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fts10onj4%2Fproduction%2F4f15f1b5bf88a631070c66706bd5b819ff6fd2d1-852x852.jpg&w=3840&q=75)
Arnold Trakhtenberg
a year ago