Skip to content

Commit

Permalink
chore: fixed merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
WasiqB committed Aug 4, 2024
2 parents 99da564 + 631c3e3 commit 7718288
Show file tree
Hide file tree
Showing 14 changed files with 1,543 additions and 4,393 deletions.
Binary file added examples/cypress/.bin/cucumber-json-formatter
Binary file not shown.
7 changes: 5 additions & 2 deletions examples/cypress/.cypress-cucumber-preprocessorrc.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"json": {
"enabled": true
"enabled": true,
"formatter": ".bin/cucumber-json-formatter",
"output": ".run/reports/json/cucumber-report.json"
},
"messages": {
"enabled": false
"enabled": true,
"output": ".run/reports/messages/cucumber-report.json"
},
"stepDefinitions": ["cypress/e2e/[filepath].step.{js,ts}"]
}
27 changes: 27 additions & 0 deletions examples/cypress/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Sample Cypress Cucumber

This is a sample project for Cypress and Cucumber with Multiple HTML Cucumber Reporter.

## Setup

Install PNPM by following the guide [here](https://pnpm.io/installation).

## Run the Test

Install the dependencies by running the following command:

```shell
pnpm install
```

Run the tests by using the following command:

```shell
pnpm test
```

Generate the HTML reporter by using the following command:

```shell
pnpm report
```
73 changes: 0 additions & 73 deletions examples/cypress/cucumber-html-report.js

This file was deleted.

67 changes: 67 additions & 0 deletions examples/cypress/cucumber-html-report.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { generate } from "multiple-cucumber-html-reporter";
import dayjs from "dayjs";
import { readFileSync } from "fs";

const data = readFileSync("./.run/results.json", {
encoding: "utf8",
flag: "r",
});
const runInfos = JSON.parse(data);

let mapOs = (os: string) => {
if (os.startsWith("win")) {
return "windows";
} else if (os.startsWith("darwin")) {
return "osx";
} else if (os.startsWith("linux")) {
return "linux";
} else if (os.startsWith("ubuntu")) {
return "ubuntu";
} else if (os.startsWith("android")) {
return "android";
} else if (os.startsWith("ios")) {
return "ios";
}
};

generate({
jsonDir: "./.run/reports/json/",
reportPath: "./.run/html-report/",
openReportInBrowser: true,
metadata: {
browser: {
name:
runInfos.browserName === "chromium" ? "chrome" : runInfos.browserName,
version: runInfos.browserVersion,
},
platform: {
name: mapOs(runInfos.osName),
version: runInfos.osVersion,
},
},
customData: {
title: "Run Info",
data: [
{ label: "Project", value: "Sample " },
{ label: "Release", value: "1.0.0" },
{ label: "Cypress Version", value: runInfos["cypressVersion"] },
{ label: "Node Version", value: runInfos["nodeVersion"] },
{
label: "Execution Start Time",
value: dayjs(runInfos["startedTestsAt"]).format(
"YYYY-MM-DD HH:mm:ss.SSS"
),
},
{
label: "Execution End Time",
value: dayjs(runInfos["endedTestsAt"]).format(
"YYYY-MM-DD HH:mm:ss.SSS"
),
},
],
},
pageTitle: "Sample",
reportName: "Sample",
displayDuration: true,
displayReportTime: true,
});
73 changes: 0 additions & 73 deletions examples/cypress/cypress.config.js

This file was deleted.

52 changes: 52 additions & 0 deletions examples/cypress/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { defineConfig } from "cypress";
import { writeFileSync } from "fs";
import createBundler from "@bahmutov/cypress-esbuild-preprocessor";
import {
addCucumberPreprocessorPlugin,
afterRunHandler,
} from "@badeball/cypress-cucumber-preprocessor";
import { createEsbuildPlugin } from "@badeball/cypress-cucumber-preprocessor/esbuild";

async function setupNodeEvents(
on: Cypress.PluginEvents,
config: Cypress.PluginConfigOptions
): Promise<Cypress.PluginConfigOptions> {
await addCucumberPreprocessorPlugin(on, config);

on(
"file:preprocessor",
createBundler({
plugins: [createEsbuildPlugin(config)],
})
);
on(
"after:run",
async (
results:
| CypressCommandLine.CypressRunResult
| CypressCommandLine.CypressFailedRunResult
): Promise<void> => {
if (results) {
await afterRunHandler(config);
writeFileSync(".run/results.json", JSON.stringify(results));
}
}
);

return config;
}

export default defineConfig({
e2e: {
specPattern: "cypress/e2e/**/*.feature",
setupNodeEvents,
defaultCommandTimeout: 60000,
pageLoadTimeout: 60000,
video: false,
experimentalInteractiveRunEvents: true,
downloadsFolder: "./cypress/.run/downloads",
fixturesFolder: "./cypress/.run/fixtures",
screenshotsFolder: "./cypress/.run/screenshots",
videosFolder: "./cypress/.run/videos",
},
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference types="Cypress"/>
/// <reference types="cypress" />

import { Given } from "@badeball/cypress-cucumber-preprocessor";

Given("I open the gmail", function () {
Given("I open the gmail", () => {
cy.visit("https://mail.google.com");
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import { Given } from "@badeball/cypress-cucumber-preprocessor";

// Import the necessary modules

Given("I open the google", function () {
Given("I open the google", () => {
cy.visit("https://www.google.co.in");
});
File renamed without changes.
19 changes: 12 additions & 7 deletions examples/cypress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@
"version": "1.0.0",
"description": "Sample Cypress project",
"main": "index.js",
"type": "module",
"scripts": {
"test": "cypress run --browser chrome --headed --reporter json",
"clean": "rm -rf dist .run",
"build": "pnpm clean && tsc",
"test": "pnpm build && cypress run --browser chrome --headed",
"report": "node dist/cucumber-html-report.js",
"cy:run": "cypress run"
},
"author": "Wasiq Bhamla",
"license": "MIT",
"devDependencies": {
"@badeball/cypress-cucumber-preprocessor": "^20.1.0",
"@cypress/browserify-preprocessor": "^3.0.2",
"cypress": "^13.13.1",
"multiple-cucumber-html-reporter": "^3.7.0"
"@badeball/cypress-cucumber-preprocessor": "^20.1.1",
"@bahmutov/cypress-esbuild-preprocessor": "^2.2.2",
"@types/node": "^22.1.0",
"cypress": "^13.13.2",
"multiple-cucumber-html-reporter": "^3.7.0",
"typescript": "^5.5.4"
},
"dependencies": {
"dayjs": "^1.11.12",
"fs": "^0.0.1-security"
"dayjs": "^1.11.12"
}
}
Loading

0 comments on commit 7718288

Please sign in to comment.