Comments (4)
I started the worker and tracker, but I still encountered a 'ConnectionRefused' error. Afterward, I will create a repository to reproduce this issue.
from zimic.
Hi, @irvile! Thanks for the detailed description.
To confirm, did you start your worker
? If you're using zimic in tests, you could add the following code to your test setup file:
beforeAll(async () => {
await worker.start()
})
afterAll(async () => {
await worker.stop()
})
Also, did you apply any mock responses to /auth/v1/admin/users
? Creating the interceptor only declares the schema, so mocking endpoints is another step, using interceptor.post
in your scenario:
const loginTracker = supabaseInterceptor
.post('/auth/v1/admin/users')
.respond({
status: 200,
body: { user: { id: '123' } },
})
// Now, POST requests to /auth/v1/admin/users will be mocked!
Finally (more of a tip), the interceptor schema declares the types of the requests and responses the endpoint accepts. In your case, I believe the following format would be more general:
const supabaseInterceptor = createHttpInterceptor<{
'/auth/v1/admin/users': {
POST: {
request: {
body: { email: string; password: string }
}
response: {
200: { body: { user: { id: string } } }
}
}
}
}>({
worker,
baseURL: process.env.SUPABASE_URL,
})
from zimic.
@irvile, as part of #34, I'm creating example projects with popular setups. As of now, I've created Node.js, JSDOM, and browser using Jest and Vitest. The examples are on canary
if you'd like to take a look and compare to your project.
Investigating more about connection refused errors, one possible cause is that MSW (and Zimic by consequence) only applies mocks to the current process, which makes it hard to use in multi-process projects (e.g. a frontend test trying to apply mocks to a backend reaching an external service). I started planning a new feature and API primitives on #75, which I'm calling "remote HTTP interceptors". I believe they could extend Zimic to multi-process cases, if yours is one of them. Let me know if you have any ideias about it!
from zimic.
Hi, @irvile!
Among other thins, v0.4 introduced remote interceptors and v0.5 improved the logs about unhandled requests. Take a look at the documentation to check if remote interceptors solve the problem you're facing.
I'll close this issue for now. Feel free to re-open it if the problem persists!
from zimic.
Related Issues (20)
- Support to Node.js 22
- Internal HTTP interceptor worker management
- Provide server exports
- Warn about interceptors with conflicting base URLs
- Rename request tracker to request handler
- Validate requests with no body
- Requests with multiple dynamic parameters are not being intercepted
- Custom error when using an invalid URL
- Force clients to disconnect when the server is stopped
- HTTP client
- HTTP namespace
- Rename `Server` to `InterceptorServer`
- Strict CLI
- Migration guide: `v0.4`
- Split Next.js example between app router and pages router
- Fix unhandled request logs on type local and browser
- Migrate links from `diego-aquino/zimic` to `zimicjs/zimic`
- Local and remote interceptor code snippets
- Improve error handling in interceptor server and computed response factories
- Investigate possible type performance problems when using `handler.with()`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zimic.