Giter Site home page Giter Site logo

keploy / typescript-sdk Goto Github PK

View Code? Open in Web Editor NEW
19.0 4.0 28.0 455 KB

Official Keploy Node SDK 🟑

Home Page: https://docs.keploy.io/

License: Apache License 2.0

TypeScript 95.56% Shell 4.44%
expressjs hacktoberfest javascript keploy mock mocking nodejs typescript data-mock data-mocking

typescript-sdk's Introduction

contributions welcome Slack License

Note :- Issue Creation is disabled on this Repository, please visit here to submit issue.

Keploy Typescript-SDK

This is the client SDK for the Keploy testing platform. With the TypeScript SDK, you can test both your existing unit test cases in Jest and create new end-to-end test cases for your applications. The HTTP mocks/stubs and tests are the same format and inter-exchangeable.

Contents

  1. Installation
  2. Usage
  3. Community support

Installation

  1. First install Node.js. Then,
# for npm package manager
npm i @keploy/sdk
# for yarn package manager
yarn add @keploy/sdk
  1. Install and Start the keploy binary on an independent terminal. Follow this guide

  2. Finally, install nyc as a development dependency using npm or yarn:

# for npm package manager
npm install --save-dev nyc
# for yarn package manager
yarn add --dev nyc

With nyc installed, you can now use it to analyze code coverage for both unit and end-to-end test cases in your project

Usage

Unit and End-to-End Testing with Keploy

Keploy simplifies the testing process by seamlessly generating end-to-end test cases without the need to write unit test files and manage mocks/stubs.

  1. Enabling Coverage To add the specified coverage-related scripts to your package.json file, you can include the following statement within the "scripts" section:

            "scripts": {
                // ... other scripts
                "test": "jest --coverage",
                "coverage": "nyc npm test && npm run coverage:merge && npm run coverage:report",
                "coverage:merge": "mkdir -p ./coverage && nyc merge ./coverage .nyc_output/out.json",
                "coverage:report": "nyc report --reporter=lcov --reporter=text"
                // ... other scripts
            }
  2. A testfile to run and display coverage Create a test file that execute Keploy's end-to-end test cases along with unit testcases. It can be called as Keploy.test.js

    The contents of the file will be

        const { expect } = require('@jest/globals');
        const keploy = require('@keploy/sdk');
        const timeOut = 300000;
    
        describe('Keploy Server Tests', () => {
            test('TestKeploy', (done) => {
                const cmd = 'npm start';
                const options = {};
                keploy.Test(cmd, options, (err, res) => { 
                    if (err) {
                        done(err);
                    } else {
                        expect(res).toBeTruthy(); // Assert the test result
                        done();
                    }
                });
            }, timeOut);
        }, timeOut);
  3. RunOptions

        options {
            delay: number; // delay for the application ro run
            debug: boolean; // enable or disable debug flag
            port: number; // port of keploy you want to run
            path: string; // path of the keploy tests and mocks
        }
  4. Test Execute

        keploy test -c "npm test" --delay 10 --coverage
  5. Get Combined coverage Execute

        keploy test -c "npm run coverage" --delay 10 --coverage

πŸŽ‰TADA: You've successfully tested end-to-end test cases alongside unit test cases without the need to write additional test files or manage mocks/stubs.

Community support

We'd love to collaborate with you to make Keploy.io great. To get started:

  • Slack - Discussions with the community and the team.
  • GitHub - For bug reports and feature requests.

typescript-sdk's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

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.