Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
7fdf752
fix import
ceceppa Mar 16, 2022
64fb28d
add `initClient`
ceceppa Mar 16, 2022
be3af77
start client-server communication
ceceppa Mar 21, 2022
c8ff784
client-server communication
ceceppa Mar 21, 2022
4ef0eb5
actions
ceceppa Mar 25, 2022
6f9293e
js interactions
ceceppa Mar 28, 2022
59a0809
wait for element
ceceppa Mar 28, 2022
5f2d2ae
fix: always update the dif images and regenerate the report
robwalkerco Apr 12, 2022
8ffec94
chore: basic code cleanup
robwalkerco Apr 12, 2022
8f16879
chore: improve typing
robwalkerco Apr 13, 2022
f3ac9dd
fix: correct createElement children spread
robwalkerco Apr 13, 2022
0188a06
chore: lint and update caniuse-lite
robwalkerco Apr 13, 2022
3b4e600
Revert "fix: correct createElement children spread"
robwalkerco Apr 13, 2022
24dd6b9
Revert "chore: improve typing"
robwalkerco Apr 13, 2022
cc3e7ea
refactor: remove custom metro config and make build more reliable
robwalkerco Apr 13, 2022
b883a94
chore: linting and TS improvements
robwalkerco Apr 13, 2022
9f4eed9
Revert "refactor: remove custom metro config and make build more reli…
robwalkerco Apr 13, 2022
521be9f
Revert "chore: linting and TS improvements"
robwalkerco Apr 13, 2022
25adbb2
chore: make build more reliable
robwalkerco Apr 13, 2022
ff186f1
chore: remove unneeded native files
robwalkerco Apr 13, 2022
4eb7c1d
refactor: only call initClient for owl builds
robwalkerco Apr 14, 2022
bf107ef
Revert "refactor: only call initClient for owl builds"
robwalkerco Apr 14, 2022
7e36434
feat: create separate entry point for react-native-owl
robwalkerco Apr 14, 2022
5141dd0
chore: prettier:fix
robwalkerco Apr 14, 2022
0515b51
fix: catch screenshot diffing error and fail test
robwalkerco Apr 14, 2022
80fa489
fix: get WebSockets working on Android
robwalkerco Apr 25, 2022
7e40afe
chore: add android baseline images
robwalkerco Apr 25, 2022
ae5b196
fix: dont generate report when updating baseline images
robwalkerco Apr 25, 2022
ebcdefa
fix: get Android working
robwalkerco Apr 25, 2022
de77aac
feat: Use ADB demo mode for consistent header content
robwalkerco Apr 25, 2022
d6f587c
chore: move SOCKET_WAIT_TIMEOUT to constantsrefactor
robwalkerco Apr 25, 2022
4e35ab2
fix: Get Android fully working with `link:../` in example project
robwalkerco Apr 25, 2022
0e926f2
Merge branch 'main' into js-interactions
robwalkerco Apr 25, 2022
96e956e
test: fix tests
robwalkerco Apr 25, 2022
f39d5a4
chore: ts lint
robwalkerco Apr 26, 2022
d74ecdb
test: improve test coverage
robwalkerco Apr 26, 2022
40a1b5f
feat: remove usesCleartextTraffic and setup access withing the library
robwalkerco Apr 26, 2022
0eade0c
feat: add ability to clear and enter text
robwalkerco Apr 26, 2022
acd402e
chore: improve logger messages
robwalkerco Apr 26, 2022
ad7d91a
test: fix tests
robwalkerco Apr 26, 2022
a0c3684
chore: improve logger messages
robwalkerco Apr 26, 2022
8af7722
chore: ts lint
robwalkerco Apr 26, 2022
6e139fb
refactor: small refactores
robwalkerco Apr 26, 2022
b0d9e45
refactor: extra error messaging
robwalkerco Apr 26, 2022
f83df70
refactor: remove some @ts-ignore's
robwalkerco Apr 26, 2022
04e0a7c
feat: add scrollTo and scrollToEnd actions
robwalkerco Apr 26, 2022
ce4c202
refactor: update demo app content and make screenshots more reliable
robwalkerco Apr 26, 2022
5d54251
feat: add long press support
robwalkerco Apr 27, 2022
4436019
feat: restore simulator settings once tests complete
robwalkerco Apr 27, 2022
fe56f08
test: update cli run tests
robwalkerco Apr 27, 2022
ff08a6c
test: tracked-elements test
robwalkerco Apr 27, 2022
5f700b3
chore: linting
robwalkerco Apr 27, 2022
06495f9
fix: get test working without requiring react
robwalkerco Apr 27, 2022
6ba5007
refactor: only create diff png's when necessary
robwalkerco Apr 27, 2022
6cd42f1
feat: clear old report and screenshots on each new run
robwalkerco Apr 27, 2022
dd8c654
refactor: file renaming
robwalkerco Apr 27, 2022
37c3e92
refactor: update imports
robwalkerco Apr 27, 2022
96f081f
test: handleAction
robwalkerco Apr 27, 2022
f3555bc
refactor: improve scrolling handling
robwalkerco Apr 27, 2022
ef95e95
test: websocket.ts
robwalkerco Apr 27, 2022
8d144be
fix: fix TS error
robwalkerco Apr 27, 2022
67b411b
tests: fix tests
robwalkerco Apr 27, 2022
250b2c0
ci: cache example app yarn deps
robwalkerco Apr 27, 2022
2f33cf6
ci: fix github action
robwalkerco Apr 27, 2022
6fdeea3
ci: fix gitbug action
robwalkerco Apr 27, 2022
1ec2406
ci: remove unneeded git hun action stuff
robwalkerco Apr 27, 2022
d09caba
test: improve websocket tests
robwalkerco Apr 27, 2022
a1ce300
fix: restore final throwing of error when running tests
robwalkerco Apr 27, 2022
36a0f57
refactor: always specify the exact ios simulator to use
robwalkerco Apr 27, 2022
0c88403
fix: consistent ios screenshots
robwalkerco Apr 27, 2022
8a7bad1
ci: trigger tests
robwalkerco Apr 27, 2022
2528413
fix: correct report image alt txt
robwalkerco Apr 28, 2022
752bf4c
refactor: make code clearer
robwalkerco Apr 28, 2022
2ba147f
feat: show failing and passing screenshots on the report
robwalkerco Apr 28, 2022
2a493d8
test: client tests
robwalkerco Apr 28, 2022
89f7bf2
fix: dont error when there are no baseline screenshots when generatin…
robwalkerco Apr 28, 2022
81ebe0d
feat: allow arbitrary callbacks on elements for Owl tests to use
robwalkerco Apr 29, 2022
df70e34
types: allow owlTestCallbacks to be optional
robwalkerco Apr 29, 2022
8a1587f
fix: always hide scroll bars for all elements even when no testID prop
robwalkerco Apr 29, 2022
8702bed
refactor: allow additional time for renders to settle and animations …
robwalkerco Apr 29, 2022
59dea78
test: fix test
robwalkerco Apr 29, 2022
de11e01
refactor: remove disconnectServer as its not required
robwalkerco Apr 29, 2022
505ba25
feat: generate the .owl .gitignore file
robwalkerco Apr 29, 2022
a1d294e
Revert "refactor: remove disconnectServer as its not required"
robwalkerco Apr 29, 2022
e7d5694
test: fix test
robwalkerco Apr 29, 2022
cd4a6a6
refactor: remove websocket client after each action.
robwalkerco Apr 29, 2022
aa439e0
test: actions.ts
robwalkerco May 3, 2022
792eec9
chore: cleanup up package dependencies
robwalkerco May 3, 2022
633b1d5
chore: update Podfile.lock
robwalkerco May 3, 2022
7e2a081
chore: fix comment typos
robwalkerco May 3, 2022
772f8d4
refactor: move the android folder to native/android
robwalkerco May 3, 2022
a307533
feat: only open WebSocket comms in Owl Android builds
robwalkerco May 3, 2022
a49dcfe
test: fix test
robwalkerco May 3, 2022
67c40f6
chore: add example of using `call` and `owlTestCallbacks` to example app
robwalkerco May 3, 2022
f868c22
chore: add ios example app baseline screenshot
robwalkerco May 3, 2022
d57e55d
test: add missing test
robwalkerco May 3, 2022
c81bb12
test: test that the client patches react
robwalkerco May 3, 2022
f85032a
fix: prevent error when diff directory does not exist
robwalkerco May 10, 2022
44b5315
fix: set Android wifi status
robwalkerco May 10, 2022
3db8948
fix: allow additional time for navigation transitions etc to complete
robwalkerco May 10, 2022
4caee60
refactor change enterText -> changeText
robwalkerco May 10, 2022
4436f69
refactor: remove `call` and related prop etc.
robwalkerco May 10, 2022
15d3966
fix: fix test
robwalkerco May 10, 2022
581aeb5
fix: control the Android navigation bar color
robwalkerco May 11, 2022
b010fb7
chore: Progress
manosim May 12, 2022
bec379e
chore: Fix tests - move react & react-native to dev dependencies
manosim May 16, 2022
a1c1cb9
chore: Minor changes
manosim May 16, 2022
5ecfd0d
chore: Clean up scripts
manosim May 17, 2022
5bf622e
fix: Fix app crashing in release mode because of lib's node modules (…
manosim May 18, 2022
2aa4738
chore: Cleanup ConfigEnv
manosim May 19, 2022
89591a3
chore: Clean up
manosim May 19, 2022
213b8fe
chore: Clean up
manosim May 19, 2022
5bdd002
docs: Add new api methods docs (#92)
robwalkerco May 19, 2022
fd98935
chore: (example app) Update android baseline images to remove the cha…
manosim May 19, 2022
d435aa7
chore: Set battery level on Android UI for consistency
manosim May 19, 2022
228bf3b
chore: Clean up
manosim May 19, 2022
5364a72
feat: Hide status bar & navigation bar on Android for screenshots
manosim May 20, 2022
879b69c
chore: Update baseline images for android
manosim May 20, 2022
6acefb7
chore: Fix tests and initial baseline
manosim May 20, 2022
925512a
chore: Fix test
manosim May 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tsconfig.json
5 changes: 3 additions & 2 deletions docs/api/matchers.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 2
sidebar_position: 3
---

# Matchers
Expand All @@ -10,13 +10,14 @@ This custom matcher will try to find and compare the baseline screenshot by usin

#### Example

```js {7}
```js title="__tests__/App.owl.tsx"
import { takeScreenshot } from 'react-native-owl';

describe('App.tsx', () => {
it('takes a screenshot of the first screen', async () => {
const screen = await takeScreenshot('homescreen');

// highlight-next-line
expect(screen).toMatchBaseline();
});
});
Expand Down
212 changes: 211 additions & 1 deletion docs/api/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ Grabs a screenshot from the simulator and stores it under `latest` screenshots(i

#### Example

```js {5}
```js title="__tests__/App.owl.tsx"
import { takeScreenshot } from 'react-native-owl';

describe('App.tsx', () => {
it('takes a screenshot of the first screen', async () => {
// highlight-next-line
const screen = await takeScreenshot('homescreen');

expect(screen).toMatchBaseline();
Expand All @@ -25,3 +26,212 @@ describe('App.tsx', () => {
The first time this test is run, or when run with the `--update` flag, the screenshot will be stored at `./owl/baseline/ios/homescreen.png` (or `/android/` is testing on Android).

On subsequent test runs, the screenshot will be stored at `./owl/current/ios/homescreen.png`.

### toExist(testID: string)

Waits for an element to exist where its `testID` prop matches the methods `testID` argument.

If there is no matching element, it will retry for 10 seconds before throwing an Error.

#### Example

```js title="App.tsx"
...
const [isLoaded, setIsLoaded] = React.useState(false);

React.useEffect(() => {
setTimeout(() => {
setIsLoaded(true);
}, 1000);
}, []);

<>
{isLoaded && (
<TextInput testId="testInput" />
)}
</>
...
```

```js title="__tests__/App.owl.tsx"
import { toExist, takeScreenshot } from 'react-native-owl';

describe('App.tsx', () => {
it('waits for an element, then takes a screenshot', async () => {
// highlight-next-line
await toExist('textInput');

const screen = await takeScreenshot('textInputExists');

expect(screen).toMatchBaseline();
});
});
```

### press(testID: string)

Calls the `onPress` prop callback of the element where its `testID` prop matches the methods `testID` argument.

If there is no matching element, it will retry for 10 seconds before throwing an Error.

The element must have a `onPress` prop, or an Error will be thrown.

#### Example

```js title="App.tsx"
...
<Button title="Press Me" testID="button" onPress={() => {
// Will be called by the react-native-owl `press` method
}} />
...
```

```js title="__tests__/App.owl.tsx"
import { press, takeScreenshot } from 'react-native-owl';

describe('App.tsx', () => {
it('presses a button with testID = `button` then takes a screenshot', async () => {
// highlight-next-line
await press('button');

const screen = await takeScreenshot('afterButtonPress');

expect(screen).toMatchBaseline();
});
});
```

### longPress(testID: string)

Calls the `onLongPress` prop callback of the element where its `testID` prop matches the methods `testID` argument.

If there is no matching element, it will retry for 10 seconds before throwing an Error.

The element must have a `onLongPress` prop, or an Error will be thrown.

#### Example

```js title="App.tsx"
...
<Button title="Long press Me" testID="button" onLongPress={() => {
// Will be called by the react-native-owl `longPress` method
}} />
...
```

```js title="__tests__/App.owl.tsx"
import { longPress, takeScreenshot } from 'react-native-owl';

describe('App.tsx', () => {
it('long presses a button with testID = `button` then takes a screenshot', async () => {
// highlight-next-line
await longPress('button');

const screen = await takeScreenshot('afterButtonLongPress');

expect(screen).toMatchBaseline();
});
});
```

### changeText(testID: string, text: string)

Calls the `onChangeText` prop callback of the element where its `testID` prop matches the methods `testID` argument.

If there is no matching element, it will retry for 10 seconds before throwing an Error.

The element must have a `onChangeText` prop, or an Error will be thrown.

#### Example

```js title="App.tsx"
...
<TextInput
testID="email"
placeholder="Enter email address"
onChangeText={setEmail}
value={email}
/>
...
```

```js title="__tests__/App.owl.tsx"
import { changeText, takeScreenshot } from 'react-native-owl';

describe('App.tsx', () => {
it('changes text in a TextInput with testID = `email` then takes a screenshot', async () => {
// highlight-next-line
await changeText('email', 'john.smith@example.com');

const screen = await takeScreenshot('afterChangeText');

expect(screen).toMatchBaseline();
});
});
```

### scrollTo(testID: string, position: {x?: number, y?: number})

Calls the `scrollTo` method of the element where its `testID` prop matches the methods `testID` argument.

If there is no matching element, it will retry for 10 seconds before throwing an Error.

The element must have a `scrollTo` method (i.e `ScrollView`), or an Error will be thrown.

#### Example

```js title="App.tsx"
...
<ScrollView testID="scrollView">
...
</ScrollView>
...
```

```js title="__tests__/App.owl.tsx"
import { scrollTo, takeScreenshot } from 'react-native-owl';

describe('App.tsx', () => {
it('scroll down the screen a bit then takes a screenshot', async () => {
// highlight-next-line
await scrollTo('scrollView', {y: 50});

const screen = await takeScreenshot('afterScrollTo');

expect(screen).toMatchBaseline();
});
});
```

### scrollToEnd(testID: string)

Calls the `scrollToEnd` method of the element where its `testID` prop matches the methods `testID` argument.

If there is no matching element, it will retry for 10 seconds before throwing an Error.

The element must have a `scrollToEnd` method (i.e `ScrollView`), or an Error will be thrown.

#### Example

```js title="App.tsx"
...
<ScrollView testID="scrollView">
...
</ScrollView>
...
```

```js title="__tests__/App.owl.tsx"
import { scrollToEnd, takeScreenshot } from 'react-native-owl';

describe('App.tsx', () => {
it('scroll down the screen a bit then takes a screenshot', async () => {
// highlight-next-line
await scrollToEnd('scrollView');

const screen = await takeScreenshot('afterScrollToEnd');

expect(screen).toMatchBaseline();
});
});
```
4 changes: 2 additions & 2 deletions docs/cli/testing-the-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ The following will be included the the output of failed tests:

```
...
[OWL] Generating Report
[OWL] Report was built at /Users/username/Code/FormidableLabs/react-native-owl/example/.owl/report/index.html
[OWL - CLI] Generating Report
[OWL - CLI] Report was built at /Users/username/Code/FormidableLabs/react-native-owl/example/.owl/report/index.html
...
```
14 changes: 11 additions & 3 deletions docs/introduction/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Use the [takeScreenshot](/docs/api/methods#takescreenshotname-string) and [.toMa
#### Example

```js
import { takeScreenshot } from 'react-native-owl';
import { press, takeScreenshot } from 'react-native-owl';

describe('App.tsx', () => {
it('takes a screenshot of the first screen', async () => {
Expand All @@ -48,6 +48,16 @@ describe('App.tsx', () => {
expect(screen).toMatchBaseline();
});
});

describe('App.tsx', () => {
it('presses a button, then takes a screenshot', async () => {
await press('button')

const screen = await takeScreenshot('afterButtonPress');

expect(screen).toMatchBaseline();
});
});
```

### Building the app
Expand All @@ -71,8 +81,6 @@ yarn owl build --platform ios
</TabItem>
</Tabs>

### Work-In-Progress

:::info

You will need to manually start the correct simulator before the tests are run.
Expand Down
2 changes: 0 additions & 2 deletions docs/introduction/work-in-progress.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ title: Work In Progress

### Future functionality

- We plan to integrate [Detox](https://wix.github.io/Detox/) into the library, and add methods to our [API](/docs/api/methods) to allow tests to interact with the app. For example, this could allow the particular button to be tapped, or screen to be scrolled, before taking and comparing a screenshot as part of a test.

- We will automate the launching to the relevant simulator, if not already running, when running tests.
Binary file added example/.owl/baseline/android/entered-text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed example/.owl/baseline/android/homescreen.png
Binary file not shown.
Binary file added example/.owl/baseline/android/initial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/.owl/baseline/android/long-press.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/.owl/baseline/android/scroll-to-end.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/.owl/baseline/android/scroll-to.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/.owl/baseline/android/test-input.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/.owl/baseline/ios/entered-text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed example/.owl/baseline/ios/homescreen.png
Binary file not shown.
Binary file added example/.owl/baseline/ios/initial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/.owl/baseline/ios/long-press.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/.owl/baseline/ios/scroll-to-end.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/.owl/baseline/ios/scroll-to.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/.owl/baseline/ios/test-input.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading