detox-rp-reporter
v1.1.1
Published
Jest custom reporter for integrating Detox E2E tests with ReportPortal analytics and reporting
Downloads
225
Readme
detox-rp-reporter
A Jest reporter that integrates Detox mobile testing framework with ReportPortal for comprehensive test reporting and analytics.
Features
- ReportPortal Integration: Uploads test results directly to ReportPortal
- Artifact Support: Automatically attaches screenshots and videos from failed tests
- Offline Mode: Run tests without real-time reporting - cache and upload later
- Always-Cache Mode: Commands cached in memory for reliable reporting
- TypeScript Support: Built with TypeScript for better developer experience
Installation
yarn add -D detox-rp-reporter
# or
npm install --save-dev detox-rp-reporterConfiguration
Environment Variables
export RP_ENDPOINT=https://your-reportportal-instance.com
export RP_API_KEY=your-api-key
export RP_PROJECT_NAME=your-project-name
export RP_LAUNCH=your-launch-name
export DETOX_ARTIFACTS_PATH=.artifactsJest Configuration
module.exports = {
reporters: [
'default',
['detox-rp-reporter', {
endpoint: process.env.RP_ENDPOINT,
apiKey: process.env.RP_API_KEY,
project: process.env.RP_PROJECT_NAME,
launch: process.env.RP_LAUNCH,
artifactsPath: process.env.DETOX_ARTIFACTS_PATH,
attributes: [
{ key: 'framework', value: 'detox' },
{ key: 'platform', value: 'mobile' }
]
}]
]
};Usage
Once configured, the reporter automatically:
- Creates a launch in ReportPortal when Jest starts
- Tracks test execution and creates test items
- Attaches screenshots and videos from failed tests
- Completes the launch when all tests finish
Artifact Handling
The reporter automatically searches for and attaches artifacts from failed tests:
- Screenshots:
testFnFailure.pngfrom failed test artifacts - Videos:
test.mp4from failed test recordings
Artifacts are searched in the Detox artifacts directory structure:
.artifacts/
└── ✗ Login Screen should login with valid credentials/
├── testFnFailure.png
└── test.mp4Configuration Options
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| endpoint | string | - | ReportPortal endpoint URL |
| apiKey | string | - | ReportPortal API key |
| project | string | - | ReportPortal project name |
| launch | string | - | Launch name |
| description | string | - | Launch description |
| mode | string | DEFAULT | Launch mode |
| artifactsPath | string | .artifacts | Path to Detox artifacts |
| attributes | array | [] | Launch attributes |
| extendTestDescriptionWithLastError | boolean | true | Include error details in test description |
| skippedIssue | boolean | true | Mark skipped tests as issues |
| offlineMode | boolean | false | Enable offline mode - cache only, no real-time reporting |
| saveToFile | boolean | true | Save cached commands to file |
| cacheFilePath | string | ./rp-cache.json | Path to cache file |
| launchId | string | - | Existing launch ID to append results |
| rerun | boolean | false | Rerun mode |
| rerunOf | string | - | UUID of launch to rerun |
Cache and File Save Mode
The reporter operates in always-cache mode, storing all commands in memory for reliable reporting. By default, commands are also saved to a file for debugging and offline replay capabilities.
Offline Mode
When you need to run tests without real-time ReportPortal connectivity:
{
"reporters": [
["detox-rp-reporter", {
"offlineMode": true, // Disable real-time reporting
"saveToFile": true, // Save commands to cache file
"cacheFilePath": "./rp-cache.json",
// ... other options
}]
]
}After running tests in offline mode, upload results with the generated replay script:
node ./rp-replay.jsFor comprehensive offline mode documentation, see OFFLINE_MODE_USAGE.md.
Requirements
- Node.js 18.x or higher
- Yarn 4.x or higher
- Jest for test running
- Detox for mobile testing framework integration
- ReportPortal instance for test reporting
Development
Building the Project
# Install dependencies
yarn install
# Build the project
yarn build
# Run linting
yarn lint
# Format code
yarn formatProject Structure
src/
├── index.ts # Main export
├── DetoxReporter.ts # Core reporter implementation
├── AsyncQueue.ts # Async operation queue
├── Storage.ts # Internal storage utility
├── helper/
│ └── OfflineMod.ts # Offline mode helper utilities
└── types/
└── reportportal.d.ts # ReportPortal type definitionsContributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Issues
If you encounter any issues, please report them on GitHub Issues.
Support
For questions and support, please contact:
- Author: Artsem Burlai
- Email: [email protected]
- Repository: detox-rp-reporter
License
MIT - see the LICENSE file for details.
Acknowledgments
- ReportPortal for the excellent test reporting platform
- Client Javascript for ReportPortal communication
- Agent JS Jest for inspiration
- Detox for the mobile testing framework
- Jest for the testing framework and reporter API
