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

have fetch pluggable #132

Closed
jacobbogers opened this issue Feb 20, 2024 · 5 comments
Closed

have fetch pluggable #132

jacobbogers opened this issue Feb 20, 2024 · 5 comments

Comments

@jacobbogers
Copy link
Contributor

jacobbogers commented Feb 20, 2024

Hi, Can you expose the "fetch" as pluggable, this would help greatly at testing especially as we dont use jest mocks (we use it.concurrent extensively will be an issue since jest mocks are global to test file)

hence the need to make it pluggable per it test

Example (just spitballing):

config: { 
    getFetch: () => globalThis.fetch
}

for mocking (integration tests)

config: { 
    getFetch: () => fetchMocked
}
@adrai
Copy link
Member

adrai commented Feb 20, 2024

If you know of a way that works without breaking all current environments (client, server, Node.js, Deno, etc.) feel free to open a PR

@jacobbogers
Copy link
Contributor Author

Thanks for your understanding, let me see if I can cook something up.

@adrai
Copy link
Member

adrai commented Feb 20, 2024

btw: I would prefer to not add additional complexity, since you can also pass your custom request function here: https://github.com/i18next/i18next-http-backend?tab=readme-ov-file#backend-options

image

@jacobbogers
Copy link
Contributor Author

I made a PR

#133

@jacobbogers
Copy link
Contributor Author

jacobbogers commented Feb 21, 2024

To answer your question about request

Sure we can use request , but our test regiment is to simulate at lowest level possible, (the actual network traffic and especially simulating errors, checking headers, or sending back incomplete data, delays, etc, etc) and see if our apps in an integration test setting can deal with this situation prorperly.

btw: I would prefer to not add additional complexity, since you can also pass your custom request function here: https://github.com/i18next/i18next-http-backend?tab=readme-ov-file#backend-options

image

@adrai adrai closed this as completed Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants