This is the client SDK for the [Keploy](https://github.com/keploy/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.
npm install @keploy/sdk


Note :- Issue Creation is disabled on this Repository, please visit here to submit issue.
bash
for npm package manager
npm i @keploy/sdk
`
`bash
for yarn package manager
yarn add @keploy/sdk
`2. Install and Start the keploy binary on an independent terminal. Follow this guide
3. Finally, install nyc as a development dependency using npm or yarn:
`bash
for npm package manager
npm install --save-dev nyc
`
`bash
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 projectUsage
$3
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:
` bash
"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
`bash
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
`bash
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
`bash
keploy test -c "npm test" --delay 10 --coverage
`5. Get Combined coverage
Execute
`bash
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.