This package contains simple utility functions to test with Remix.run.
npm install --save-dev remix-testing-utils
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: {},
})
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: {},
});
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: {},
});
- MIT License