# Mocha

Last updated on : 09 Jan 2026

Overview

Mocha is a widely-used JavaScript testing framework operating on Node.js that streamlines the testing process for JavaScript applications. It offers a user-friendly and adaptable environment for validating code, ensuring its correctness and dependability.

### Key Features

- Ease of Use: Simple to install and initiate, seamlessly integrating into JavaScript projects
- Flexibility: Functions in both browser and server-side settings, suitable for various JavaScript applications
- Precision: Generates comprehensive and precise test reports with informative error messages and stack traces
- Versatility: Supports mobile app testing on both iOS and Android platforms via Pcloudy
- Works with assertion libraries to produce high-quality JavaScript applications

## Prerequisites

Before setting up Mocha for mobile testing, ensure you have:

1.  Node.js and NPM - Latest versions installed on your system
2.  Pcloudy Account - Active account with valid credentials
3.  API Access Key - Available in your account profile or Quick Actions tab
4.  Mobile App Upload - Your Android (.apk) or iOS (.ipa) application uploaded to Pcloudy via the web interface
5.  Project Files - Clone the project into an empty directory

## Setup Instructions

1. Install Dependencies

Navigate to your project directory and run the following command to install required packages from package.json:

```java
npm install
```

2. Configure Test Environment

Edit the conf/singleDevice.conf.js file with your credentials. The sample below shows the basic structure—refer to the Capability Generator page for a complete customized configuration tailored to your needs:

```java
Pcloudy_Username: "your-email@example.com"
Pcloudy_ApiKey: "your-api-access-key"
```

Configuration Parameters:

- Pcloudy_Username: Your registered email address
- Pcloudy_ApiKey: Your API access key (found in account profile or Quick Actions tab)

## Running Tests

Single Device Execution

Open the terminal in your project directory and execute:

```java
npm run android
```

This command will launch the Mocha test suite on a single Android device in the Pcloudy cloud.

## Troubleshooting

Common Issues:

- Authentication failed - Verify your username and API key are correct in the configuration file
- App not found - Ensure the app is uploaded and filename matches exactly in configuration
- Device not available - Check device name spelling or try a different device
- Dependencies not installed - Run npm install to ensure all packages are installed properly

## Additional Resources

- Complete samples and documentation: Pcloudy GitHub Repository
- Support: support@pcloudy.com
