-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed release workflow and added cypress example
- Loading branch information
Showing
14 changed files
with
15,350 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,8 @@ reports/ | |
.DS_Store | ||
yarn.lock | ||
*.tgz | ||
|
||
videos/ | ||
screenshots/ | ||
downloads/ | ||
*.ndjson |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"json": { | ||
"enabled": true | ||
}, | ||
"messages": { | ||
"enabled": false | ||
}, | ||
"stepDefinitions": ["cypress/e2e/[filepath].step.{js,ts}"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
const report = require("multiple-cucumber-html-reporter"); | ||
const dayjs = require("dayjs"); | ||
const fs = require("fs"); | ||
|
||
const data = fs.readFileSync("./reports/cypress-report.json", { | ||
encoding: "utf8", | ||
flag: "r", | ||
}); | ||
const runInfo = JSON.parse(data); | ||
|
||
const osName = () => { | ||
switch (runInfo["osName"]) { | ||
case "win32": | ||
return "windows"; | ||
case "linux": | ||
return "ubuntu"; | ||
default: | ||
console.log("Undefined OS"); | ||
} | ||
}; | ||
|
||
const browserName = () => { | ||
switch (runInfo["browserName"]) { | ||
case "chrome": | ||
return "Chrome"; | ||
case "firefox": | ||
return "Firefox"; | ||
case "edge": | ||
return "Edge"; | ||
case "webkit": | ||
return "Safari"; | ||
default: | ||
console.log("Undefined Browser"); | ||
} | ||
}; | ||
|
||
report.generate({ | ||
jsonDir: "./reports/cucumber-json", | ||
reportPath: "./reports", | ||
metadata: { | ||
browser: { | ||
name: browserName(), | ||
version: runInfo["browserVersion"], | ||
}, | ||
platform: { | ||
name: osName(), | ||
version: runInfo["osVersion"], | ||
}, | ||
}, | ||
customData: { | ||
title: "Run Info", | ||
data: [ | ||
{ label: "Project", value: "Sample " }, | ||
{ label: "Release", value: "1.0.0" }, | ||
{ label: "Cypress Version", value: runInfo["cypressVersion"] }, | ||
{ label: "Node Version", value: runInfo["nodeVersion"] }, | ||
{ | ||
label: "Execution Start Time", | ||
value: dayjs(runInfo["startedTestsAt"]).format( | ||
"YYYY-MM-DD HH:mm:ss.SSS" | ||
), | ||
}, | ||
{ | ||
label: "Execution End Time", | ||
value: dayjs(runInfo["endedTestsAt"]).format("YYYY-MM-DD HH:mm:ss.SSS"), | ||
}, | ||
], | ||
}, | ||
pageTitle: "Sample", | ||
reportName: "Sample", | ||
displayDuration: true, | ||
displayReportTime: true, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
const { defineConfig } = require("cypress"); | ||
const fs = require("fs"); | ||
const preprocessor = require("@badeball/cypress-cucumber-preprocessor"); | ||
const browserify = require("@badeball/cypress-cucumber-preprocessor/browserify"); | ||
|
||
function createReportJsonMeta(results) { | ||
fs.writeFileSync( | ||
"./reports/generated/results.json", | ||
JSON.stringify( | ||
{ | ||
browserName: results.browserName, | ||
browserVersion: results.browserVersion, | ||
osName: results.osName, | ||
osVersion: results.osVersion, | ||
nodeVersion: results.config.resolvedNodeVersion, | ||
cypressVersion: results.cypressVersion, | ||
startedTestsAt: results.startedTestsAt, | ||
endedTestsAt: results.endedTestsAt, | ||
}, | ||
null, | ||
"\t" | ||
) | ||
); | ||
} | ||
async function setupNodeEvents(on, config) { | ||
await preprocessor.addCucumberPreprocessorPlugin(on, config); | ||
|
||
on("file:preprocessor", browserify.default(config)); | ||
on("after:run", async (results) => { | ||
if (results) { | ||
createReportJsonMeta(results); | ||
let sourcePath = "./reports/cucumber-json"; | ||
let oldExtension = "cucumber.json"; | ||
let newExtension = | ||
results.browserName + "." + new Date().getTime() + ".json"; | ||
fs.readdir(sourcePath, (err, files) => { | ||
if (err) { | ||
cy.log("Issue in the file reading"); | ||
return; | ||
} | ||
|
||
files.forEach((file) => { | ||
const oldFilePath = `${sourcePath}/${file}`; | ||
|
||
if (file.endsWith(`.${oldExtension}`)) { | ||
const newFilePath = `${sourcePath}/${file.replace( | ||
`.${oldExtension}`, | ||
`.${newExtension}` | ||
)}`; | ||
fs.rename(oldFilePath, newFilePath, (err) => { | ||
if (err) { | ||
cy.log("Issue in the file renaming"); | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
} | ||
}); | ||
|
||
return config; | ||
} | ||
|
||
module.exports = defineConfig({ | ||
e2e: { | ||
specPattern: "cypress/e2e/**/*.feature", | ||
setupNodeEvents, | ||
defaultCommandTimeout: 60000, | ||
pageLoadTimeout: 60000, | ||
video: false, | ||
reporter: "json", | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Feature: Gmail Opening | ||
|
||
Scenario: Gmail | ||
|
||
Given I open the gmail | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/// <reference types="Cypress"/> | ||
|
||
import { Given } from "@badeball/cypress-cucumber-preprocessor"; | ||
|
||
Given("I open the gmail", function () { | ||
cy.visit("https://mail.google.com"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Feature: Google Opening | ||
|
||
Scenario: Google | ||
|
||
Given I open the google | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/// <reference types="cypress" /> | ||
|
||
import { Given } from "@badeball/cypress-cucumber-preprocessor"; | ||
|
||
// Import the necessary modules | ||
|
||
Given("I open the google", function () { | ||
cy.visit("https://www.google.co.in"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "hello@cypress.io", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// *********************************************** | ||
// This example commands.js shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add('login', (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// *********************************************************** | ||
// This example support/e2e.js is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands' | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |
Oops, something went wrong.