Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ jobs:
- name: Run the e2e suite
run: npm run test:e2e

# The report is built whether the tests passed or failed. Failed tests carry the game screenshot and the driver log.
- name: Build the Allure report
if: always() && hashFiles('allure-results/*.json') != ''
run: npm run report

- name: Upload the Allure report
if: always() && hashFiles('allure-report/index.html') != ''
uses: actions/upload-artifact@v4
with:
name: allure-report
path: allure-report
retention-days: 7

# Only this job's copy, matched by its path: another runner on the same machine may have a game open
- name: Stop the sample game
if: always()
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ dist
*.tsbuildinfo
.DS_Store
*.png
allure-results
allure-report
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ token on CI.
| `@alttester/driver` | The binding: `AltDriver`, `AltObject`, `By`, `AltKeyCode`, enums, typed exceptions |
| `@alttester/driver/protocol` | The low-level protocol client the web inspector uses (`AltSocket`, app list, live view) |
| `@alttester/driver/node` | Node-only helpers: `AltReversePortForwarding` (adb reverse, iproxy) |
| `@alttester/driver/allure` | Optional: puts AltTester screenshots and the driver log into an Allure report |
| `@alttester/driver/testing` | The in-memory fake AltServer, for consumers' own tests |

The package was split out of [alttester-web](https://github.com/alttester), the browser-based AltTester
Expand Down Expand Up @@ -68,6 +69,28 @@ Errors follow the other bindings: `NotFoundException` (and `ObjectNotFound`, `Co
`AppDisconnectedException`, `InvalidCommandException`, `AltTesterInvalidServerResponse`, ...; all extend
`AltException`.

## Allure reports

`@alttester/driver/allure` attaches AltTester material to the test that is running, in any test runner that has an
Allure adapter (allure-vitest, allure-mocha, allure-jest, allure-playwright or @wdio/allure-reporter). It needs the
`allure-js-commons` package next to that adapter. Nothing else in the driver uses it, so the package is optional.

```ts
import { AltDriver } from '@alttester/driver';
import { attachFailureEvidence, createLogRecorder } from '@alttester/driver/allure';

const log = createLogRecorder(); // keeps the driver log in memory instead of printing it
const driver = await AltDriver.connect({ appName: 'MyGame', enableLogging: log });

// In your runner's after-test hook, when the test failed:
await attachFailureEvidence(driver, { log });
```

`attachFailureEvidence` attaches a game screenshot and the driver log. Pass `object` to add a screenshot with that
object outlined, and `hierarchy: true` to add every loaded object as JSON. It never throws: an item it can't collect
becomes a "not available" note. `attachScreenshot`, `attachHighlightedScreenshot`, `attachHierarchy` and `attachLog`
attach one item each, at any point in a test.

## Differences from the other bindings

- Async, and `AltDriver.connect()` instead of a constructor.
Expand All @@ -84,6 +107,8 @@ Errors follow the other bindings: `NotFoundException` (and `ObjectNotFound`, `Co

`npm test` runs the unit tests against an in-memory fake server. `npm run test:live` runs against real apps;
see `test/live/README.md`.
`npm run test:e2e` runs the sample-game suite (see `test/e2e/README.md`) and writes Allure results; `npm run report`
turns them into `allure-report/`, and `npm run report:open` opens it.

## Development

Expand Down
Loading
Loading