# FastReportService

A WebdriverIO service that sends immediate email notifications for failed tests with the `fastReport` property in their metadata.

Add on every test step were the fast report is need it: 
browser.addTestMeta({ zephyrStep: "205139", fastReport: '' });

## Overview

The FastReportService monitors test execution and automatically sends email notifications when tests fail that have been marked for fast reporting. This service is ideal for critical tests that require immediate attention when they fail.

## Installation

1. Ensure you have the required dependencies:
   ```bash
   npm install nodemailer --save-dev
   ```

2. Place the `FastReportService.js` file in your project's `services` directory.

## Configuration

Add the FastReportService to your WebdriverIO configuration file (wdio.conf.js):

```javascript
import FastReportService from './services/FastReportService.js';

export const config = {
    // ... other WebdriverIO config
    
   services: [
    [FastReportService, {
            // Email sender configuration
            from: "automated-notifications@mail.com",
            to: "", // list of receivers
            bcc: "bcc@gmail.com",
            // Email subject prefix
            subjectPrefix: 'Fast report testing FAILURE detected',
            // Nodemailer transport options
            transportOptions: {
              host: 'SMTPMAIL.xx.xx.xx',
              port: 25,
              secure: false,
              tls: { rejectUnauthorized: false }
            },
        }]
  ],
}
```

### Configuration Options

| Option | Type | Description |
|--------|------|-------------|
| `from` | String | The email sender address |
| `subjectPrefix` | String | Text to include at the beginning of the email subject |
| `transportOptions` | Object | Nodemailer transport configuration object |

## Usage

To mark a test for fast reporting, add a `fastreport` property to the test metadata:

```javascript
it('should perform a critical function', async () => {
    browser.addTestMeta({
        zephyrKey: "TEST-123",
        fastreport: {
            priority: "high",
            component: "Login",
            owner: "Auth Team"
        }
    });
    
    // Test code
});
```

The `fastreport` property can be a simple boolean or an object with additional details:

```javascript
// Simple flag
browser.addTestMeta({
    fastreport: true
});

// With details
browser.addTestMeta({
    fastreport: {
        priority: "high",
        component: "Payment",
        owner: "Finance Team"
    }
});
```

## Email Format

When a test with the `fastreport` property fails, the service will send an email with:

1. **Text format** - A plain text email with test failure details
2. **HTML format** - A formatted HTML email with styled failure information

The email includes:
- Test execution information (timestamp, browser, platform)
- Test details (title, parent suite)
- Error message

## Example Email

### HTML Format
![Example HTML Email](example-email.png)

### Text Format
```
Test Failure Report
====================

Date: 7/15/2023, 3:45:02 PM
Browser: chrome
Platform: linux

```

## Integration with Allure

For tests that trigger a fast report, the service adds a description to the Allure report indicating that a notification was sent. 