Skip to content

Commit

Permalink
Merge pull request #1 from saucelabs/init
Browse files Browse the repository at this point in the history
Init cypress-junit-plugin
  • Loading branch information
tianfeng92 authored Feb 9, 2024
2 parents 3f4640e + e727eb6 commit 8c7292c
Show file tree
Hide file tree
Showing 24 changed files with 11,450 additions and 30 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/lib
14 changes: 14 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:cypress/recommended',
'plugin:prettier/recommended',
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'cypress'],
root: true,
env: {
node: true,
},
};
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @saucelabs/devx
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Release

on:
workflow_dispatch:
inputs:
releaseType:
description: 'Release type - major, minor or patch'
required: false
default: 'patch'

jobs:
publish-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Install Dependencies
run: npm ci

- name: Setup Git
run: |
git config --global user.name "devx-sauce-bot"
git config --global user.email "devx.bot@saucelabs.com"
- name: Login to NPM
run: npm set "//registry.npmjs.org/:_authToken" ${{ secrets.NPM_TOKEN }}

- name: Release
run: npm run release:ci -- ${{ github.event.inputs.releaseType }}
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
63 changes: 63 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Tests

on:
pull_request:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Install Dependencies
run: npm ci

- name: Lint
run: npm run lint
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Install Dependencies
run: npm ci

- name: Build
run: npm run build

integration-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Install Dependencies
run: npm ci

- name: Run Integration Tests
run: npm run test
44 changes: 15 additions & 29 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
node_modules
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
Expand Down Expand Up @@ -42,8 +42,8 @@ build/Release
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo
Expand All @@ -54,9 +54,6 @@ web_modules/
# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
Expand All @@ -72,41 +69,29 @@ web_modules/
# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
# dotenv environment variables file
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

Expand All @@ -119,12 +104,13 @@ dist
# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# Cypress specific files
tests/integration/cypress/screenshots/*
tests/integration/cypress/videos/*


# Exclude build folder.
/lib

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
# Generated JUnit file.
junit.xml
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/lib
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
78 changes: 77 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,77 @@
# cypress-junit-plugin
# @saucelabs/cypress-junit-plugin

`@saucelabs/cypress-junit-plugin` is a third-party plugin designed to enhance your Cypress testing workflow by generating comprehensive JUnit test reports.

Please be aware that this plugin is not an official product of Sauce Labs.

## Unique Features

Unlike Cypress' built-in [junit reporter](https://docs.cypress.io/guides/tooling/reporters), this plugin generates a single, consolidated JUnit file for the entire test run, rather than individual files per spec that then need to be merged.

## Prerequisites

**Cypress Version**: This plugin is compatible with Cypress version 13 and above. Make sure your project is updated to meet this version requirement.

## Installation

To install the plugin, run the following command in your project directory:

```bash
npm install @saucelabs/cypress-junit-plugin --save-dev
```

## Configuration

After installation, configure the plugin to work with your Cypress setup.

### `cypress.config.mjs` Example:

```javascript
import { defineConfig } from 'cypress';
import { setupJUnitPlugin } from '@saucelabs/cypress-junit-plugin';

export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
setupJUnitPlugin(on, config, { filename: "path/to/my_junit.xml" });
return config;
}
},
});
```

### `cypress.config.cjs` Example:

```javascript
const { defineConfig } = require('cypress');
const { setupJUnitPlugin } = require('@saucelabs/cypress-junit-plugin');

module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
setupJUnitPlugin(on, config, { filename: 'path/to/my_junit.xml' });
return config;
},
},
});
```

## Usage

Simply run your Cypress tests as usual. The plugin will automatically generate a JUnit report at the specified location (default: `junit.xml`) after the test run is complete.

```bash
cypress run
```

## Contributing

Contributions to the `@saucelabs/cypress-junit-plugin` are welcome! Check out our contributing guidelines for more information on how to participate.

## Support

If you run into any issues or have questions about the plugin, feel free to open an issue on our GitHub repository.

## License

This plugin is released under the [MIT License](LICENSE).
Loading

0 comments on commit 8c7292c

Please sign in to comment.