A Mock GitHub API for testing integrations.
A Mock GitHub API for testing integrations.
This project is just an idea. Barely anything is implemented.
// Start the server
const port = 5000
const server = await mocktokit(port, webhook)
// Create an octokit client with a custom baseUrl
const octokit = require('@octokit/rest')({
baseUrl: 'http://localhost:5000'
})
// Now you can start making API requests to the mock server
// Just by using octokit
// At any moment you can get an immutable snapshot of the state
const state1 = server.getState()
// Modify something by using regular octokit methods
await octokit.issues.create({
owner: 'gimenete',
repo: 'test-repo',
title: 'One issue'
})
// Take another snapshot
const state2 = server.getState()
// You can assert any snapshot
console.log('state1', state1)
console.log('state2', state2)
See the example.js
file for a full example.
@octokit/rest
methods to create an in-memory mock serverbefore()
hook of your test suite to run multiple tests with the same environment.Implement a web UI similar to github.com using Primer so a user can easily:
This also would lower the barrier to create probot applications. Initially you won't have to create a GitHub app, nor any webhook integration. You would be able to start writing your application and see a UI similar to github.com seeing the results of your code and the ability to interact with it and thus, triggering events to the probot application.