Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

detox-copilot

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detox-copilot - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

4

dist/actions/StepPerformer.js

@@ -37,3 +37,3 @@ "use strict";

cacheFilePath;
constructor(context, promptCreator, codeEvaluator, snapshotManager, promptHandler, cacheFileName = 'step_performer_cache.json') {
constructor(context, promptCreator, codeEvaluator, snapshotManager, promptHandler, cacheFileName = 'detox_copilot_cache.json') {
this.context = context;

@@ -44,3 +44,3 @@ this.promptCreator = promptCreator;

this.promptHandler = promptHandler;
this.cacheFilePath = path.resolve(process.cwd(), 'copilot-cache', cacheFileName);
this.cacheFilePath = path.resolve(process.cwd(), cacheFileName);
}

@@ -47,0 +47,0 @@ getCacheKey(step, previous) {

@@ -8,2 +8,5 @@ "use strict";

const Copilot_1 = require("../Copilot");
jest.mock('fs', () => ({
readFileSync: jest.fn().mockReturnValue('{}')
}));
describe('Integration', () => {

@@ -10,0 +13,0 @@ let mockFrameworkDriver;

{
"name": "detox-copilot",
"version": "0.0.8",
"version": "0.0.9",
"description": "A flexible plugin that drives your tests with human-written commands, enhanced by the power of large language models (LLMs)",

@@ -5,0 +5,0 @@ "keywords": [

@@ -8,8 +8,95 @@ # Detox Copilot

## Quick Demo
Here's an example of how Copilot runs over a Detox test case:
<img src="copilot-demo.gif" width="800">
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, this is a **work in progress** and the final APIs may differ from this.
High-level overview of the API that Detox Copilot exposes:
- `init(config)`: Initializes the Copilot with the provided configuration, must be called before using Copilot. The configuration includes the LLM service endpoint and the framework's driver.
- `reset()`: Resets the Copilot by clearing the previous steps. This is required to start a new test case with a clean context.
- `perform(steps)`: Performs a testing operation or series of testing operations in the app based on the given step intents (string or array of strings).
```typescript
/**
* Initializes the Copilot with the given configuration.
* Must be called before any other Copilot methods.
* @param config The configuration for the Copilot.
*/
init: (config: Config) => void;
/**
* Resets the Copilot instance.
* Must be called before each test to ensure a clean state (the Copilot uses the operations history as part of
* its context).
*/
reset: () => void;
/**
* Performs a testing operation or series of testing operations in the app based on the given `steps`.
* @returns The result of the operation(s), which can be a single value or an array of values for each step.
* @example Tap on the login button
* @example Scroll down to the 7th item in the Events list
* @example The welcome message should be visible
* @example The welcome message text should be "Hello, world!"
* @example [
* 'Tap on the login button',
* 'A login form should be visible',
* ]
*/
perform: (steps: string | string[]) => Promise<any | any[]>;
```
## 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
```typescript
/**
* Sends a prompt to the AI service and returns the response.
* @param prompt The prompt to send to the AI service.
* @param image Optional path to the image to upload to the AI service that captures the current UI state.
* @returns The response from the AI service.
*/
runPrompt: (prompt: string, image?: string) => Promise<string>;
/**
* Checks if the AI service supports snapshot images for context.
*/
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
```typescript
/**
* Takes a snapshot of the current screen and returns the path to the saved image.
* If the driver does not support image, return undefined.
*/
captureSnapshotImage: () => Promise<string | undefined>;
/**
* Returns the current view hierarchy in a string representation.
*/
captureViewHierarchyString: () => Promise<string>;
/**
* The available API methods of the testing framework.
*/
apiCatalog: TestingFrameworkAPICatalog;
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc