Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zoxios-nock

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zoxios-nock

Nock creation using zoxios definitions

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ZoXios Nock

A testing package that returns a nock scope when provided a zoxios request-maker.

Features

  • Provide a mock for zoxios http request definitions.

installation

Install peer dependencies

npm i zoxios axios zod

Install zoxios

npm i zoxios-nock

Basic usage

Parsing request's query and response's body.

import { zoxios } from 'zoxios';
import { zoxiosNock } from 'zoxios-nock';

describe('when provided a GET request', () => {
const requestMaker = zoxios('http://google.com')
    .method('get')
    .concatPath('api')
    .responseSchema(
      z.object({ name: z.string(), age: z.number().min(0).max(120) }),
    );

    it('should return GET scope', async () => {
        // Providing zoxiosNock a requestMaker from zoxios.
        const scope = zoxiosNock(getRequestMaker);
        const response = await getRequestMaker.exec();

        expect(response).toMatchObject({
            name: expect.any(String),
            age: expect.any(Number),
        });
        expect(scope.isDone()).toBeTruthy();
    });
});

Keywords

FAQs

Package last updated on 17 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc