Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrated to PNPM from NPM #292

Closed
wants to merge 1 commit into from
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
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,25 @@ version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
target-branch: "main"
versioning-strategy: increase
open-pull-requests-limit: 100
schedule:
interval: "weekly"
timezone: "Asia/Calcutta"
groups:
dependencies:
dependency-type: "production"
dev-dependencies:
dependency-type: "development"

- package-ecosystem: "github-actions"
directory: "/"
target-branch: "main"
open-pull-requests-limit: 100
schedule:
interval: "weekly"
timezone: "Asia/Calcutta"
groups:
dependencies:
dependency-type: "production"
21 changes: 14 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:

env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
PUSH_TOKEN: ${{ secrets.PUSH_TOKEN }}

jobs:
release:
Expand All @@ -25,9 +26,18 @@ jobs:
ref: "main"
fetch-depth: 0

- uses: actions/setup-node@v4
- uses: pnpm/action-setup@v2
with:
node-version: 16
version: latest

- name: Setup Node v18
uses: actions/setup-node@v4
with:
node-version: 18
cache: "pnpm"

- name: Install dependencies
run: pnpm i

- name: NPM Setup
run: npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
Expand All @@ -37,10 +47,7 @@ jobs:
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"

- name: Install Dependencies
run: npm ci

- name: Release
run: npm run release.ci -- ${{github.event.inputs.releaseType}}
run: pnpm release.ci -- ${{ github.event.inputs.releaseType }}
env:
GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }}
GITHUB_TOKEN: ${{ env.PUSH_TOKEN }}
17 changes: 9 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@ jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16]

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
- uses: pnpm/action-setup@v2
with:
version: latest

- name: Setup Node v18
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version: 18
cache: "pnpm"

- name: Install dependencies
run: npm ci
run: pnpm i

- name: Run Unit Tests and generate coverage report
run: npm run unit.test.coverage
run: pnpm unit.test.coverage
4 changes: 2 additions & 2 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Contributing
============
# Contributing

We try to achieve a 100% coverage on the Javascript code. Please make sure that each addition reaches this goal.

## Tests

- clone the project to your local machine
- do a npm install

Expand Down
63 changes: 37 additions & 26 deletions docs/WEBDRIVER.IO.MD
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
webdriver.io
============
# webdriver.io

> **NOTE:<br>**
> If you are using WebdriverIO V4 follow the instructions below, if you are using WebdriverIO V5, please check [here](https://github.com/wswebcreation/wdio-cucumberjs-json-reporter).

Follow the installation instructions as mentioned in [Install](../README.MD#install)

## Using wdio-cucumber-framework version 2.2.0 or higher?

If you are using the latest version of `wdio-cucumber-framework` version `2.2.0` or higher, you can now use a new reporter called [wdio-multiple-cucumber-html-reporter](https://github.com/wswebcreation/wdio-multiple-cucumber-html-reporter).
It works nicely with this reporter.

## Using wdio-cucumber-framework version lower than 2.2.0?
> **NOTE: THIS INSTRUCTION ONLY WORKS WITH `CucumberJS` V2 AND THUS `wdio-cucumber-framework` V1.1.1. I'M WORKING ON A SOLUTION FOR THE LATEST VERSION OF `CucumberJS` V4 AND THUS `wdio-cucumber-framework` > V2.0.0**

> **NOTE: THIS INSTRUCTION ONLY WORKS WITH `CucumberJS` V2 AND THUS `wdio-cucumber-framework` V1.1.1. I'M WORKING ON A SOLUTION FOR THE LATEST VERSION OF `CucumberJS` V4 AND THUS `wdio-cucumber-framework` > V2.0.0**
> **THIS REPORT WORKS BASED ON EXTRA PROVIDED BROWSER INFO IN THE REPORT. PLEASE FOLLOWING THE INSTRUCTIONS BELOW / IN THE README.MD TO ADD THAT INFO. IF YOU DON'T YOU MAY GET ERRORS GENERATING THE REPORT**

## Step 1: Add extra dependency

Add an extra dependency to your project so you can save the extra JSON-files.

`npm install fs-extra --save-dev`

This dependency will be used in the next step.

## Steps 2: Create a report hook

Create a file called `report.hook.js` and save it in your project. I always have a specific folder in which I save my configs and hooks like `./e2e/config/hooks`.

This hook will do the following:

- is will take the complete report (of all features that have been run) and cut it into small reports per feature.
- each report will get the instance data that is needed to show the name/version of the browser/platform in the report, see the comments in the hook, see also [MetaData](../README.MD#metadata-1)


Add the following code to it:

```js
import Cucumber, { defineSupportCode } from 'cucumber';
import { ensureDirSync, writeJsonSync } from 'fs-extra';
import { join } from 'path';
import Cucumber, { defineSupportCode } from "cucumber";
import { ensureDirSync, writeJsonSync } from "fs-extra";
import { join } from "path";

const jsonFormatter = new Cucumber.JsonFormatter();
const projectRoot = process.cwd();
Expand Down Expand Up @@ -64,21 +65,30 @@ defineSupportCode(({ registerListener }) => {
function adjustAndSaveJsonFile(capabilities, report) {
const jsonReport = JSON.parse(report);
if (jsonReport.length > 0) {
const featureName = jsonReport[0].name.replace(/\s+/g, '_').replace(/\W/g, '').toLowerCase() || 'noName';
const snapshotPath = join(projectRoot, '.tmp/json-output');
const filePath = join(snapshotPath, `${featureName}.${capabilities.browserName}.${(new Date).getTime()}.json`); // eslint-disable-line
const featureName =
jsonReport[0].name
.replace(/\s+/g, "_")
.replace(/\W/g, "")
.toLowerCase() || "noName";
const snapshotPath = join(projectRoot, ".tmp/json-output");
const filePath = join(
snapshotPath,
`${featureName}.${
capabilities.browserName
}.${new Date().getTime()}.json`
); // eslint-disable-line

// The report is enriched with data of the running instance, this is needed to show the name/version of the browser/platform in the report
jsonReport[0].metadata = {
browser: {
name: capabilities.browserName,
version: '60' // Add your version or dynamically add your version here
version: "60", // Add your version or dynamically add your version here
},
device: "local development machine",
platform: {
name: 'osx', // Add your platform name here
version: '10.12.6' // Add your platform version here
}
name: "osx", // Add your platform name here
version: "10.12.6", // Add your platform version here
},
};

ensureDirSync(snapshotPath);
Expand All @@ -90,36 +100,37 @@ defineSupportCode(({ registerListener }) => {
```

## Step 3: Create an after scenario hook

If you want to attach a screenshot after failure to the report hook create a file called `after.scenario.js` and save it to your project.

```js
import { After, Status } from 'cucumber';
import { After, Status } from "cucumber";

After(function (scenarioResult) {
if (scenarioResult.status === Status.FAILED) {
// Attach the original state
const screenshot = browser.saveScreenshot();
world.attach(screenshot, 'image/png');
world.attach(screenshot, "image/png");
}

return Promise.resolve(scenarioResult.status);
});

```

### Step 4: Change the wdio.config

Add the following lines of code to your `wdio.conf.js` file (or however you call it). See [Options](../README.MD#options) for more options

```js
const report = require('multiple-cucumber-html-reporter'); // this will add the reporter to your config

// Add a `onComplete`-hook with the following data.
onComplete: () => {
report.generate({
jsonDir: '.tmp/json-output/',
reportPath: '.tmp/report/'
});
}
const report = require("multiple-cucumber-html-reporter"); // this will add the reporter to your config

// Add a `onComplete`-hook with the following data.
onComplete: () => {
report.generate({
jsonDir: ".tmp/json-output/",
reportPath: ".tmp/report/",
});
};
```

The `jsonDir` will tell the module where to find the the generated JSON-report files, the `reportPath` will be the path to where the reports are saved.
Loading
Loading