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

ynn-mock

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ynn-mock

Mocking data for Ynn

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ynn-mock

Mocking data for Ynn

Installation

$ npm i --save-dev ynn-mock

Usage

mock.rsc

Mocking data for RSC request for test cases.

mock.rsc( app, uri, response )

mock.rsc( app, response )

mock.rsc.restore( app )

const mock = require( 'ynn-mock' );

const app = new Ynn( {
    root : __dirname, 
    debugging : false,
    logging : false
} );

describe( 'Ynn test', () => {

    beforeAll( async () => {
        await app.ready();
        await mock.rsc( app, 'service:the/api', { n : 1 } );

        // To mock response data for all URIs.
        await mock.rsc( app, { n : 2 } );
    } );

    afterAll( () => mock.rsc.restore( app ) );

    it( 'should use mock response for "service:the/api"', async () => {
        const res = app.rsc.call( 'service:the/api' ); 
        expect( res ).toEqual( { n : 1 } ); // pass
    } );

    it( 'should use mock response which does not specify an URI', async () => {
        const res = app.rsc.call( 'api/that/is/not/mock' );
        expect( res ).toEqual( { n : 2 } ); // pass
    } );
} );

mock.service

const mock = require( 'ynn-mock' );

describe( 'mock.service', () => {
    it( 'desc', async () => {
        const app = new Ynn( {
            root : __dirname,
            debugging : true,
            logging : false
        } );

        await mock.service( app, 'serviceName', {
            property1 : value,
            property2 : value
            ...
        } )

    } );
} );

Keywords

FAQs

Package last updated on 09 Mar 2022

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