Skip to content

takagimeow/remix-testing-utils

Repository files navigation

Remix Testing Utils NPM version CI License: MIT

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

About

Utils to make testing in Remix easier.

Resources

License

Stars

Watchers

Forks

Packages

No packages published