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

Feature: synchronously generate a mock object according to a spec without a server or middleware #34

Open
daniellizik opened this issue Oct 27, 2021 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@daniellizik
Copy link

Hello, thanks for this library! I use it at work to run faked e2e tests, this lib is a big help.

Is your feature request related to a problem? Please describe.

While this lib works great with an express server, it would be nice to be able synchronously generate mocked objects without a need for a server.

I use this lib for testing, but it would also be great for e2e documentation in Storybook. I am envisioning a setup where we have our component stories pre-populated with mocked fixtures, this lets us document the full user flow from frontend to server.

Describe the solution you'd like

Currently, I would need to deploy an express server along with the build Storybook bundle (it just gets built as a static js bundle), so having the ability to do something like this would be awesome

const openApiMock = new OpenApiMock({ spec: 'path/to/doc' })

const Template: Story<React.ComponentProps<typeof Review>> = () => <Review />;

export default {
  title: 'something',
  component: SomeComponent
} as Meta;

export const Default = Template.bind({});
Default.parameters = {
  // synchronously generates mock api response
  apiResult: openApiMock.produce({
    // provide http request params that would match a request described by the openapi doc
    route: '/blah',
    query: { locale: 'en' },
    body: { ...bodyParams }
  })
};
@daniellizik daniellizik changed the title Feature: generate a mock object according to a spec without a server or middleware Feature: synchronously generate a mock object according to a spec without a server or middleware Oct 27, 2021
@aleksandryackovlev aleksandryackovlev added the enhancement New feature or request label Jan 28, 2022
@aleksandryackovlev aleksandryackovlev self-assigned this Jan 28, 2022
@aleksandryackovlev
Copy link
Owner

Seems like a usefull feature. I've added it to the roadmap for the next major version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants