cypress-easy-network-stub
    TypeScript icon, indicating that this package has built-in type declarations

    1.3.1 • Public • Published

    cypress-easy-network-stub

    An easy class to mock a lot of network requests in cypress

    npm version

    Example:

    const posts = [0, 1, 2, 3, 4, 5].map(x => ({ postId: x, text: `test${x}` }));
    
    const blogStub = new CypressEasyNetworkStub('/MyServer/api/Blog');
    
    blogStub.init();
    
    blogStub.stub('GET', 'posts', (body, params) => {
      return posts;
    });
    
    blogStub.stub('GET', 'posts/{id:number}', (body, params) => {
      return posts.find(x => x.postId === params.id);
    });
    
    blogStub.stub('POST', 'posts', (body, params) => {
      posts.push({ postId: body.postId, text: body.text });
    });
    
    blogStub.stub('POST', 'test/{something:boolean}?{query:string}&{secondQuery:number}', (body, params) => {
      console.log(params.something);
      console.log(params.query);
      console.log(params.secondQuery);
    });

    Strongly typed api parameters: 28e1ce4ebde1baee92f4cb40a23452ab

    Keywords

    none

    Install

    npm i cypress-easy-network-stub

    DownloadsWeekly Downloads

    82

    Version

    1.3.1

    License

    MIT

    Unpacked Size

    28.3 kB

    Total Files

    43

    Last publish

    Collaborators

    • loaderb0t