Detox Copilot
A flexible plugin that drives your tests with human-written commands, enhanced by the power of large language models (LLMs).
While originally designed for Detox, Detox Copilot can be extended to any other testing frameworks.
It provides clear APIs to perform actions and assertions within your tests while interfacing with an LLM service to enhance the testing process.
Quick Demo
Here's an example of how Copilot runs over a Detox test case:
The test case is written in a human-readable format, and Copilot translates it into Detox actions on the fly.
Not just Detox! Copilot can be extended to any other testing frameworks.
API Overview
High-level overview of the API that Detox Copilot exposes:
init: (config: Config) => void;
reset: () => void;
perform: (steps: string | string[]) => Promise<any | any[]>;
Additional Note
In addition to the operations history, Copilot maintains a repository-level cache. If you need to ignore the current cache for any reason (e.g., when adding an action to the testing framework driver), you can set the environment variable COPILOT_OVERRIDE_CACHE
to "true" before running your tests. This will ensure that the current cache is not taken into consideration and will override the existing one.
export COPILOT_OVERRIDE_CACHE=true
If you want to disable the override after setting it to "true" and revert to using the cache, you can set COPILOT_OVERRIDE_CACHE
to "false"
export COPILOT_OVERRIDE_CACHE=false
Integration with Testing Frameworks
Detox Copilot requires two main components to work:
Prompt Handler
An adapter that interfaces with the LLM service to generate actions based on the provided prompts. For example, GPT, Gemini, Sonnet or any other LLM service.
PromptHandler
Interface
runPrompt: (prompt: string, image?: string) => Promise<string>;
isSnapshotImageSupported: () => boolean;
Testing Framework Driver
An adapter that interfaces with the testing framework to execute the generated actions. For example, Detox, Appium, Espresso, XCTest or any other testing framework.
In order for Copilot to work with the testing framework, the driver provides the API catalog and the JS context to execute the generated actions.
TestingFrameworkDriver
Interface
captureSnapshotImage: () => Promise<string | undefined>;
captureViewHierarchyString: () => Promise<string>;
apiCatalog: TestingFrameworkAPICatalog;