remix-testing-utils
v0.1.1
Published
A set of utility functions and types to make testing in Remix easier
Downloads
2
Maintainers
Readme
Remix Testing Utils
This package contains simple utility functions to test with Remix.run.
Installation
npm install --save-dev remix-testing-utils
API Reference
createLoaderRequest
This createLoaderRequest function is used to create a dummy instance of the request needed when testing the loader function.
const req = createLoaderRequest("http://localhost:3000/", {
cookie: "__session=helloworld"
});
await loader({
request: req,
context: {},
params: {},
})
createActionRequest
This createActionRequest function is used to generate a dummy instance of the request needed when testing the action function.
const req = createActionRequest("http://localhost:3000/", {
id: "user-id",
name: "user-name",
});
await action({
request: req,
context: {},
params: {},
});
createStripeWebhookRequest
This createsStripeWebhookRequest function is not directly related to Remix, but is used to create a dummy of the request instance needed when testing the Stripe webhook implemented by the action function.
const request = createStripeWebhookRequest(
"http://localhost:3000/api/webhook/stripe",
"stripe-signature",
customerSubscriptionUpdatedEventPayload
);
await action({
request,
context: {},
params: {},
});
Author
License
- MIT License