Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(blog): introduce Detox Copilot. #4596

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

asafkorem
Copy link
Contributor

No description provided.

@asafkorem asafkorem self-assigned this Sep 30, 2024

Detox Copilot leverages advanced Large Language Models (LLMs) to interpret natural language instructions and translate them into Detox actions and assertions. This means you can describe your test scenarios in everyday language, aligning perfectly with **Behavior-Driven Development (BDD)** principles.

### Why Natural Language Testing?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we also need to preset the benefits of the reduced maintenance cost (i.e. thanks to the decoupling from specific test ID's, not to mention xpath, etc). Let's try to come up with some examples? It's too important to be overlooked 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100%

Comment on lines +11 to +15
gosha212:
name: Georgy Steshin
title: Detox Core Contributor
url: https://github.com/jonathanmos
image_url: https://github.com/jonathanmos.png
url: https://github.com/gosha212
image_url: https://github.com/gosha212.png
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅


### Seamless Integration with Detox

Detox Copilot is built into Detox and requires no additional installation. Simply initialize it in your test setup, and you're ready to start writing natural language tests.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good stuff!


Initialize Detox Copilot in your test setup by implementing a `PromptHandler` that connects to your LLM service. This abstraction allows Detox Copilot to communicate with any LLM you choose, promoting versatility across different testing frameworks.

In our [Testing with Copilot guide](https://wix.github.io/Detox/docs/next/guide/testing-with-copilot), you can find implementation examples and more detailed descriptions for this part.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/next/...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, next/ is the most up-to-date docs (on master). I'll try to use the latest published version instead.

**Hybrid Example:**

```javascript
it('should add an item to the cart', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good example

const pageTitle = await copilot.perform(
'Launch the app',
'Navigate to the "Profile" page',
'Return the text of the page title'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woah, can't believe this actually works (!)

);

// Use the returned value in a hard-coded assertion
jestExpect(pageTitle).toBe('Profile');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm isn't this discouraged? I wonder

Copy link
Contributor Author

@asafkorem asafkorem Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, yeahhh.. you're right. not the best example for this ability. smells like a bad practice 😄 . I'll try to come with a better one / remove it


You can also use Copilot for locating the elements and then use them in your hard-coded assertions.

**Locating Elements Example:**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really cool!


In our [Testing with Copilot guide](https://wix.github.io/Detox/docs/next/guide/testing-with-copilot), you can find implementation examples and more detailed descriptions for this part.

### Step 2: Write Tests Using Natural Language
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be a part of the "Testing with CoPilot" guide?

'Verify that the product is listed in the cart'
);
});
```
Copy link
Collaborator

@d4vidi d4vidi Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, what about attributes inspection (as prompts)?

  • Color assertions
  • Element size
  • Value of progress bar / check-box / etc

Maybe this is a 1st in a whole new set of questions we can ask, IDK

@d4vidi
Copy link
Collaborator

d4vidi commented Oct 1, 2024

+ Need'a update the dir-structure doc
image

@d4vidi
Copy link
Collaborator

d4vidi commented Oct 1, 2024

Not directly related of course, but I think we REALLY need to offer the community with out-of-the-box implementations for this... If the goal was to call for contributions on that, then let's voice that more explicitly 💬

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants