GitHub Next Logo


TestPilot takes the pain out of writing unit tests. It uses GitHub Copilot's AI technology to suggest tests based on your existing code and documentation. Unlike many other tools, TestPilot generates readable tests with meaningful assertions, and it can iteratively improve its suggestions based on your feedback.

What's it for?
Generate unit tests from code and documentation
Who made it?
User Statement
As a
software developer
I want to
write good unit tests for my code
it is time consuming and boring, so I end up postponing it.
TestPilot helps by
suggesting readable unit tests based on my code and documentation
other test generators that focus on coverage and produce tests that are hard to understand.

Want to write good unit tests for your code but it just takes too much time, or add tests to a legacy code base but don’t know where to start? Let TestPilot suggest unit tests based on your existing source code and documentation!

What can TestPilot do?

Leveraging the cutting-edge machine-learning models powering GitHub Copilot, TestPilot creates readable unit tests with meaningful assertions for your JavaScript/TypeScript code.

When you point it at a function in a code repo, TestPilot will scan the repo for relevant doc comments and code examples, and then generate a unit test for the function based on the information it finds. You can run the test straight away, and if it doesn't pass you can feed back any errors you are seeing to TestPilot and interactively refine the generated test until it's just right.

For example, consider the method Deque.prototype.clear from the js-sdsl package. The package documentation contains the following code example for this method:

const v = new Vector([1, 2, 3])
console.log(v.size()) // 0
console.log(v.empty()) // true

From this example, TestPilot constructs the following test:

const assert = require('chai').assert
const js_sdsl = require('js-sdsl')
describe('test js_sdsl', function () {
  it('test js_sdsl.Deque.prototype.clear', function () {
    let v = new js_sdsl.Deque([1, 2, 3])
    assert.equal(v.size(), 0)
    assert.equal(v.empty(), true)

Does it work in practice?

We have taken TestPilot through its paces on a number of popular (and not so popular) npm packages and measured statement coverage of the generated tests, and found that it often achieves 60-80% coverage. Here is a sneak peek at our results so far:

PackageStatement coverage

We are currently working on a detailed write-up which we'll link from here soon.

How can I try it out?

TestPilot is still in the prototyping stage. Stay tuned for a demo!