Giter VIP home page Giter VIP logo

next-testing-api's Introduction

Welcome to my profile โ€” I wish you a great stay!
Let me know if you have any idea, what could be our next challenge ๐Ÿ‘‹

marpme's contribution

connect with me:

marpme's blog marpme at dev.to marpme at mastodon

next-testing-api's People

Contributors

alexandros-megas avatar dependabot[bot] avatar github-actions[bot] avatar marpme avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

next-testing-api's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): lock file maintenance

Detected dependencies

github-actions
.github/workflows/lint.yml
  • actions/checkout v3
  • actions/setup-node v3
.github/workflows/npm-publish.yml
  • actions/checkout v3
  • actions/setup-node v3
.github/workflows/prettier.yml
  • actions/checkout v3
  • actions/setup-node v3
.github/workflows/testing.yml
  • actions/checkout v3
  • actions/setup-node v3
npm
package.json
  • @commitlint/cli ^17.3.0
  • @commitlint/config-conventional ^17.3.0
  • @typescript-eslint/eslint-plugin ^5.46.0
  • eslint ^8.29.0
  • eslint-import-resolver-typescript 3.5.3
  • eslint-plugin-import 2.27.5
  • eslint-plugin-jsx-a11y 6.7.1
  • eslint-plugin-react 7.32.2
  • eslint-plugin-react-hooks 4.6.0
  • husky ^8.0.2
  • lerna ^6.1.0
  • prettier ^2.8.1
  • node >=16
packages/api/package.json
  • @next/env ^13.0.6
  • @commitlint/cli ^17.3.0
  • @commitlint/config-conventional ^17.3.0
  • @types/node ^18.11.10
  • @typescript-eslint/eslint-plugin ^5.46.0
  • @typescript-eslint/parser 5.54.1
  • @vitest/coverage-c8 ^0.29.0
  • eslint ^8.29.0
  • eslint-import-resolver-typescript 3.5.3
  • eslint-plugin-import 2.27.5
  • eslint-plugin-jsx-a11y 6.7.1
  • eslint-plugin-react 7.32.2
  • eslint-plugin-react-hooks 4.6.0
  • husky ^8.0.2
  • next ^13.0.6
  • prettier ^2.8.1
  • react ^18.2.0
  • react-dom ^18.2.0
  • typescript ^4.9.3
  • vitest ^0.29.0
  • next ^13.0.6
  • node >=14.6.0

  • Check this box to trigger a request for Renovate to run again on this repository

Add setQuery method to NextApiRequestBuilder for specifying req.query

Is your feature request related to a problem? Please describe.
I would like to be able to test endpoints that use URL parameters via req.query.foo. For example, the following might be found in
pages/api/echo/[foo].ts

export async function echoFoo(req: NextApiRequest, res: NextApiResponse): Promise<void> {
  const foo = req.query.foo as string;
  res.status(200).json({ echo: foo })
}

Describe the solution you'd like
The ability to pass a query object to NextApiRequestBuilder via a method such as setQuery. Example:

  it('echoes foo', async () => {
    const req = new NextApiRequestBuilder().setMethod('GET').setQuery({ foo: 'hello' }).build();
    const res = ResponseMock<unknown>();

    await echoFoo(req, res);
    // assert things...
  });

Describe alternatives you've considered
I tried calling setUrl('...') hoping that it might be checking the filesystem routing to parse it and set the query correctly, but it doesn't have any effect.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.