TestPilot
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.
- Purpose
- Generate unit tests from code and documentation
- First published
- Stage
- Completed, archived Open source
- As a
- software developer
- I want to
- write good unit tests for my code
- But
- 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
- Unlike
- 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])
v.clear()
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])
v.clear()
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 are some examples:
| Package | Statement coverage |
|---|---|
| bluebird | 68.2% |
| image-downloader | 75.8% |
| js-sdsl | 36.5% |
| simple-statistics | 80.1% |
| zip-a-folder | 88.0% |
A detailed write-up is available on arXiv.
How can I try it out?
TestPilot has been open-sourced under the MIT license and is available at https://github.com/githubnext/testpilot.
Related work
Product Mar 2023
Copilot for Pull Requests
Pull requests are a central part of the GitHub user experience. Copilot for PRs brings the power of Copilot to the PR experience, to help you write better PR descriptions, and to help your team review and merge PRs faster.


Andrew, Devon, and 5 others
Completed Mar 2022
GitHub Copilot Labs
A VS Code extension for experimental applications of GitHub Copilot.


Irene, Idan, and Amelia
Product Mar 2023
Copilot for Docs
How would it feel to have an expert on hand at all times? We built a tool that uses relevant information from a project’s documentation to answer questions or explain concepts.


Amelia, Aqeel, and 5 others
Product Mar 2023
Copilot Completions in the CLI
Ever having trouble remembering shell commands and flags for this or that? Ever wish you could just say what you want the shell to do? Don’t worry: we’re building GitHub Copilot assistance right into your terminal.

Johan and Matt
Product Jun 2021
GitHub Copilot
The first generative AI code assistant to reach developers at scale, built and incubated at GitHub Next.


Oege, Albert, and 13 others
Prototype May 2025
Discovery Agent
Agentic Setup, Build, and Testing of Repositories.


Tamás, David, and Rahul
Completed Apr 2024
Copilot Workspace
An agentic dev environment, designed for everyday tasks.


Don, Eddie, and 5 others
Product Nov 2023
Copilot Next Edit Suggestions
Can we improve Copilot code completion by suggesting the next logical change, wherever it is in your project?


Krzysztof and 3 others
1 of