Skip to content
Open
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
42 changes: 42 additions & 0 deletions .changeset/aws-device-farm-support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
"appwright": minor
---

Add AWS Device Farm provider support for mobile testing

This release introduces comprehensive AWS Device Farm integration for mobile app testing, enabling teams to run tests on real devices in AWS's device cloud.

### Features
- **AWS Device Farm Provider**: Complete implementation with support for both Android and iOS testing
- **Automated App Upload**: Automatically uploads APK/IPA files to Device Farm during test setup
- **ARN Persistence**: Intelligently reuses uploaded builds across test runs to minimize upload time
- **Remote Session Management**: Creates and manages Device Farm remote access sessions
- **Video Recording**: Automatic video capture of test sessions with download capability
- **Flexible Configuration**: Support for custom capabilities, interaction modes, and session settings

### Technical Details
- Added comprehensive test suite with 15 tests covering all functionality
- Implemented proper async cleanup callbacks for resource management
- Enhanced error handling with descriptive error messages
- Added support for AWS region configuration
- Improved WebDriver connection handling with query parameter support

### Configuration Example
```typescript
export default defineConfig({
use: {
platform: Platform.ANDROID,
buildPath: "./app.apk",
device: {
provider: "aws-device-farm",
projectArn: "arn:aws:devicefarm:us-west-2:123:project:456",
deviceArn: "arn:aws:devicefarm:us-west-2::device:789",
region: "us-west-2",
sessionName: "My Test Session",
remoteRecordEnabled: true,
},
},
});
```

This provider enables teams to leverage AWS Device Farm's extensive device library for comprehensive mobile testing without maintaining physical device labs.
8 changes: 8 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env sh
echo "🔍 Running pre-commit lint check..."
npm run lint || {
echo "❌ ESLint failed. Please fix linting errors before committing."
echo "💡 Run 'npm run lint -- --fix' to auto-fix some issues."
exit 1
}
echo "✅ Lint check passed!"
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# appwright

## 0.3.0

### Minor Changes

- 9415229: feat: add Visual Trace Service for automatic screenshot capture during test execution

- Implements automatic screenshot capture with smart defaults (only captures for failed tests)
- Adds screenshot deduplication using SHA-256 hashing
- Supports configurable screenshot limits (default: 50)
- Integrates with Playwright's trace configuration modes
- Works with both test-scoped device and worker-scoped persistentDevice fixtures
- Provides proper test isolation and retry support
- Includes comprehensive unit test coverage

## 0.2.1

### Patch Changes

- 493ddf8: Add horizontal scroll directions (left/right) to ScrollDirection enum and update documentation with examples

## 0.2.0

### Minor Changes

- 3730adf: Upgrade to Appium v3.1, update bundled iOS driver support, bump the minimum Node.js runtime to 20.19.0, and let BrowserStack/LambdaTest configs request their Appium server version.

## 0.1.46

### Patch Changes
Expand Down
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default defineConfig({
- `platform`: The platform you want to test on, such as 'android' or 'ios'.

- `provider`: The device provider where you want to run your tests.
You can choose between `browserstack`, `lambdatest`, `emulator`, or `local-device`.
You can choose between `browserstack`, `lambdatest`, `emulator`, `local-device`, or `aws-device-farm`.

- `buildPath`: The path to your build file. For Android, it should be an APK file.
For iOS, if you are running tests on real device, it should be an `.ipa` file. For running tests on an emulator, it should be a `.app` file.
Expand Down Expand Up @@ -135,6 +135,33 @@ the provider in your config.
},
```

#### Run tests on AWS Device Farm

Appwright can connect to AWS Device Farm remote access sessions. Configure the provider in your config and supply either a Device Farm `appArn` or a local `buildPath` that Appwright can upload during global setup.

```ts
{
name: "ios",
use: {
platform: Platform.IOS,
appBundleId: "com.example.myapp",
buildPath: "./builds/MyApp.ipa",
device: {
provider: "aws-device-farm",
projectArn: "arn:aws:devicefarm:us-west-2:123456789012:project:abc123",
deviceArn:
"arn:aws:devicefarm:us-west-2::device:Apple:iPhone.15.Pro:17.5",
interactionMode: "VIDEO_ONLY",
sessionName: "smoke-suite",
},
},
},
```

Set the `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and (optionally) `AWS_SESSION_TOKEN` & `AWS_REGION` environment variables before running the tests.

Appwright will request Device Farm video recordings by default (`remoteRecordEnabled: true`) and attach the MP4 to Playwright reports once the session completes.

## Run the sample project

To run the sample project:
Expand Down
41 changes: 41 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ providers are supported:
- `emulator`
- `browserstack`
- `lambdatest`
- `aws-device-farm`

### BrowserStack

Expand All @@ -37,6 +38,46 @@ These environment variables are required for the LambdaTest

LambdaTest also requires `name` and `osVersion` of the device to be set in the projects in appwright config file.

### AWS Device Farm

AWS Device Farm can provide remote iOS and Android devices using [remote access sessions](https://docs.aws.amazon.com/devicefarm/latest/developerguide/remote-access.html).

Set these environment variables before running tests:

- `AWS_ACCESS_KEY_ID`
- `AWS_SECRET_ACCESS_KEY`
- `AWS_SESSION_TOKEN` (if you are using temporary credentials)
- `AWS_REGION` (defaults to `us-west-2` if omitted)

Sample configuration:

```ts
defineConfig({
projects: [
{
name: "ios-aws",
use: {
platform: "ios",
appBundleId: "com.example.myapp",
buildPath: "./build/MyApp.ipa",
device: {
provider: "aws-device-farm",
projectArn: "arn:aws:devicefarm:us-west-2:123456789012:project:abc123",
deviceArn:
"arn:aws:devicefarm:us-west-2::device:Apple:iPhone.15:16.4.1",
interactionMode: "VIDEO_ONLY",
sessionName: "e2e smoke",
},
},
},
],
});
```

If you already have an uploaded application in Device Farm, supply `appArn` to skip uploading the build during `globalSetup`. For Android tests, provide `appPackage` and `appActivity` when Device Farm should launch a specific activity. Any custom Appium capabilities can be added through `additionalCapabilities`.

Video recordings are downloaded automatically when `remoteRecordEnabled` is `true` (the default). Set it to `false` if you prefer to skip video capture.

### Android Emulator

To run tests on the Android emulator, ensure the following installations are available. If not, follow these steps:
Expand Down
Loading