Skip to main content
Version: 2.0.0

How to use mock library ?

The external calls from unit tests will be recorded and replayed as mocks from yaml files under a directory named mocks.

Following is an example of unit test with octokit :


var {NewContext} = require("typescript-sdk/dist/mock/mock");
var assert = require("assert");
const {Octokit, App} = require("octokit");
describe("routes", function () {
  var server, octokit;
  beforeEach(function () {
  NewContext({Mode: "record", Name: "your demo app name"}); // Set your keploy mode and name here.
  // Clears the cache so a new server instance is used for each test.
  // delete require.cache[require.resolve('../app')];

  octokit = new Octokit({auth: "your authentication token"});
  // Test to make sure URLs respond correctly.
  it("url/", async function () {
  return new Promise(function (resolve) {{}).then((result) => {
    assert.equal(, "your github username");