Skip to content
Closed
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
Binary file added .DS_Store
Binary file not shown.
83 changes: 83 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Build, Test and Release

on:
push:
branches:
- main
- development
pull_request:
branches:
- main
- development

# Release-please için gerekli izinler
permissions:
contents: write
pull-requests: write
issues: write

jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 'latest'

- name: Install dependencies
run: npm install

- name: Lint
run: npm run lint

- name: Build
run: npm run build

- name: Link
run: npm link

- name: Load env variables for tests
working-directory: __tests__
run: |
touch .env
echo "API_KEY=${{ secrets.API_KEY }}" >> .env
echo "BASE_URL=${{ secrets.BASE_URL }}" >> .env

- name: Install dependencies for tests
working-directory: __tests__
run: npm install

- name: Link
working-directory: __tests__
run: npm link @qaflow/report

- name: Make jest executable
working-directory: __tests__
run: chmod +x ./node_modules/.bin/jest

- name: Run tests
working-directory: __tests__
run: npm run test

release-please:
name: Create Release
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
needs: build-and-test

steps:
- name: Create or Update Release PR
uses: googleapis/release-please-action@v4
with:
release-type: node
config-file: .release-please-config.json
manifest-file: .release-please-manifest.json
token: ${{ secrets.ACTIONS_SECRET }}
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_SECRET }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/node_modules

/coverage.data
/coverage/

/dist
33 changes: 33 additions & 0 deletions .release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"packages": {
".": {
"release-type": "node",
"package-name": "@qaflow/report",
"changelog-path": "CHANGELOG.md",
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": true,
"draft": false,
"prerelease": false,
"include-v-in-tag": true,
"pull-request-title-pattern": "chore(release): v${version}",
"changelog-sections": [
{ "type": "feat", "section": "Features", "hidden": false },
{ "type": "fix", "section": "Bug Fixes", "hidden": false },
{ "type": "docs", "section": "Documentation", "hidden": false },
{ "type": "perf", "section": "Performance Improvements", "hidden": false },
{ "type": "refactor", "section": "Code Refactoring", "hidden": false },
{ "type": "chore", "section": "Miscellaneous", "hidden": false },
{ "type": "style", "section": "Styles", "hidden": true },
{ "type": "test", "section": "Tests", "hidden": true }
],
"extra-files": [
{
"type": "json",
"path": "package.json",
"jsonpath": "$.version"
}
]
}
},
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
}
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "1.0.0"
}
154 changes: 152 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,152 @@
# qaflow-report
A module for test reporting, compatible with test frameworks.
# QAFlow Report

QAFlow Report is a comprehensive reporting module for your test automation efforts. It seamlessly integrates with Playwright, Jest, and other test frameworks.

## Installation

```bash
npm install @qaflow/report
# or
yarn add @qaflow/report
# or
pnpm add @qaflow/report
```

## Quick Start

### Creating a Configuration File

To use QAFlow Report, you need to create a configuration file that contains your API key. You can generate this file using the following command:

```bash
npx @qaflow/report init
```

This command will interactively prompt you for your API key and generate a `reporter.config.js` or `reporter.config.ts` file.

Alternatively, you can specify your API key directly:

```bash
npx @qaflow/report init --key=<apiKey>
```

The generated configuration file will look like this:

#### `reporter.config.js`
```javascript
module.exports = {
apiKey: 'YOUR_API_KEY_HERE',
}
```

#### `reporter.config.ts`
```typescript
export default {
apiKey: 'YOUR_API_KEY_HERE'
};
```

### Basic Usage

To use the reporter in your test files:

```javascript
// Import the reporter
import reporter from "@qaflow/report";

// Create a test
reporter.createTest(
"Login Test", // Test name
"Testing the login functionality of our application", // Description
{ author: "QA Tester", email: "tester@example.com" }, // Tester info
{ name: "Chrome", version: "118.0.0", os: "macOS", browser: "Chrome" } // Environment
);

// Add test steps
await reporter.step("Navigate to the login page", () => {
return true; // Step successful
});

await reporter.step("Enter username", () => {
return true;
});

// End the test and retrieve results
const results = await reporter.end();
console.log(`Total steps: ${results.summary.total}`);
console.log(`Passed steps: ${results.summary.passed}`);
console.log(`Failed steps: ${results.summary.failed}`);
console.log(`Skipped steps: ${results.summary.skipped}`);
```

## API Usage

### `reporter.initialize(apiKey, options)`

If you are not using a configuration file, you can initialize the reporter programmatically:

```javascript
reporter.initialize("your-api-key-here");
```

### `reporter.createTest(testName, description, tester, environment)`

Creates a new test and registers it as the active test:

```javascript
reporter.createTest(
"Search Test",
"Tests the search functionality on the homepage",
{ author: "QA Tester", email: "tester@example.com" },
{ name: "Firefox", version: "115.0", os: "Windows" }
);
```

### `reporter.step(name, fn, options)`

Adds a step to the active test and executes it:

```javascript
// Successful step
await reporter.step("Navigate to homepage", () => {
return true;
});

// Failed step
await reporter.step("Perform login", () => {
throw new Error("Login failed");
});

// Skipped step
await reporter.step("View profile", () => {}, { skipped: true });

// Step with screenshot
await reporter.step("Verify search results", () => {
return true;
}, { screenshot: "base64-screenshot-data" });
```

### `reporter.end()`

Ends the active test and sends results to the API:

```javascript
const results = await reporter.end();
console.log("Test result:", results);
```

## Documentation

For detailed documentation, visit [QAFlow Docs](https://qaflow.tech/docs).

## Website

Learn more about QAFlow at [QAFlow Website](https://qaflow.tech/).

## 📜 License
This project is licensed under the [MIT License](LICENSE).

## 👤 Author
- GitHub: [@QA-Flow](https://github.com/QA-Flow)
- Author Github: [@dorukozgen](https://github.com/dorukozgen)
- LinkedIn: [Doruk](https://www.linkedin.com/in/dorukozgen)
17 changes: 17 additions & 0 deletions __tests__/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

/node_modules

/playwright-report/
/blob-report/
/playwright/.cache/

/test-results/

/coverage.data
/coverage/

/dist

node_modules/

.env
6 changes: 6 additions & 0 deletions __tests__/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
presets: [
['@babel/preset-env', {targets: {node: 'current'}}],
'@babel/preset-typescript',
],
};
30 changes: 30 additions & 0 deletions __tests__/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* For a detailed explanation regarding each configuration property, visit:
* https://jestjs.io/docs/configuration
*/

import type {Config} from 'jest';

const config: Config = {
testMatch: [
"**/jest/**/*.test.ts",
],
preset: "ts-jest",
testEnvironment: "node",
collectCoverage: true,
coverageDirectory: "test-results/jest/coverage",
coverageReporters: ["json", "lcov", "text", "clover", "html"],
reporters: [
"default",
["jest-junit", {
outputDirectory: "test-results/jest/junit",
outputName: "junit-report.xml"
}],
["jest-html-reporter", {
outputPath: "test-results/jest/html/test-report.html"
}]
],
verbose: true,
};

export default config;
Loading
Loading