Skip to content

Instantly share code, notes, and snippets.

@xiongemi
Created April 11, 2022 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save xiongemi/f837311ea3639243c30be09dbfc3a87a to your computer and use it in GitHub Desktop.
Save xiongemi/f837311ea3639243c30be09dbfc3a87a to your computer and use it in GitHub Desktop.
example detox e2e tests for search flow
import { device, element, by, expect } from 'detox';
describe('Search', () => {
beforeEach(async () => {
await device.reloadReactNative();
});
it('should show a list of results and go to film details', async () => {
await waitFor(element(by.id('search-page')))
.toBeVisible()
.withTimeout(5000);
await expect(element(by.id('search-input'))).toBeVisible();
await element(by.id('search-input')).clearText();
await element(by.id('search-input')).typeText('totoro');
await element(by.id('search-button')).tap();
await waitFor(element(by.id('results-page')))
.toBeVisible()
.withTimeout(5000);
await element(by.id('result-list-item')).atIndex(0).tap();
await waitFor(element(by.id('film-page')))
.toBeVisible()
.withTimeout(5000);
await expect(element(by.id('title'))).toBeVisible();
await expect(element(by.id('title'))).toHaveText(
'My Neighbor Totoro'
);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment