This application is about automate web pages supported by nodejs and webdriverio.
- Nodejs
- Webdriverio
- GitHub Actions
- GitHub Pages
- Docker
- MS SQL Server
- Cucumber
- Allure reporter
- Cucumber Reporter
- Chai
- SuperTest
- TypeScript
- Winston
- npm init
- npm run test:demo (running all tests with demo tag)
- npm run test:smoke (running all tests with smoke tag)
- npm run test:debug (running all tests with debug tag)
- npm run test:grid (runnig all tests with demo tag in docker grid)
To execute grid strategy tests with Docker, run code below:
- docker-compose up
- npm run test:grid
- 'npm init wdio . or npm init wdio'
- Check module type: "type":"module" ---> if this code is missed (need to add lines above).
-
check "module": "ESNext"s
-
check "resolveJsonModule": true
-
add "esModuleInterop": true,
-
change "strict":falses
-
Aditional values in this file(tsconfig.json) would not generate type errors:
"types": [ "node", "webdriverio/async", "@wdio/cucumber-framework", "expect-webdriverio", "@wdio/globals/types" ]
-
check "project: "./tsconfig.json"
e.g. tsNodeOpts: { ---> project: './tsconfig.json', transpileOnly: true }
-
add "${process.cwd()}/test/features/**/*.feature"
e.g. specs: [ `${process.cwd()}/test/features/**/*.feature` ],
-
add "./test/features/step-definitions/*.ts"
e.g. cucumberOpts: { // <string[]> (file/dir) require files before executing features require: ['./test/features/step-definitions/*.ts'], }
npm install --save-dev winston
import logger from '../../helpers/logger.ts';
-- calling logger:
logger.info() --> insert ur respective method of logger.
---> Requirement for this type of report is Java 8.
1 * Installing allure commandline:
npm install -g allure-commandline
2 * Command to view allure path:
Windows --> "where allure"
Mac ------> "which allure"
3 * Set flags into wdio.conf.ts file:
disableWebdriverStepsReporting:true,
useCucumberStepReporter: true
4 * command to open allure report
allure serve
reportedEnvironmentVars: {
Environment: process.env.ENVIRONMENT_TEST
}
if (process.env.RUNNER === "LOCAL" && fs.existsSync("./allure-results")) {
fs.rmdirSync("./allure-results", {
recursive: true
})
}
reporters: [
// Like this with the default options, see the options below
'cucumberjs-json',
// OR like this if you want to set the folder and the language
[ 'cucumberjs-json', {
jsonFolder: '.tmp/new/',
language: 'en',
},
],
],
import fs from 'node:fs/promises'
// Import the module
import { generate } from 'multiple-cucumber-html-reporter'
onPrepare: () => {
// Remove the `.tmp/` folder that holds the json and report files
return fs.rm('.tmp/', { recursive: true });
},
generate({
// Required
// This part needs to be the same path where you store the JSON files
// default = '.tmp/json/'
jsonDir: '.tmp/json/',
reportPath: '.tmp/report/',
// for more options see https://github.com/wswebcreation/multiple-cucumber-html-reporter#options
});
npm install multiple-cucumber-html-reporter --save-dev
npm i fs-extra
npm install wdio-cucumberjs-json-reporter --save-dev
npm install --save-dev supertest
https://ladjs.github.io/superagent/
async function GET(testid: string, baseUrl: string, endpoint: string, authToken: string, queryParam: Object) {
if (!(baseUrl || endpoint)) throw Error(`One of the given values BaseUrl: ${baseUrl}, endpoint: ${endpoint} is not valid`);
baseUrl = baseUrl.trim()
endpoint = endpoint.trim()
reporter.addStep(testid, "info", `Making a GET request to ${baseUrl}${endpoint}`)
try {
return await request(baseUrl).get(endpoint).query(queryParam).auth(authToken, { type: 'bearer' }).set("Content-Type", "application/json").set("Accept", "application/json")
} catch (error) {
throw error;
}
}
Refer to this npm page --instructions are provided
Link:
https://www.npmjs.com/package/wdio-geckodriver-service
npm install wdio-geckodriver-service --save-dev
npm i --save-dev geckodriver
> Add another capability object in capabilities array with browserName as firefox.
>Add a new service as "geckodriver"
1. npm i --save-dev mssql
2. npm i --save-dev @types/mssql
3. npm i --save-dev msnodesqlv8
to run a simple ts file use "npx tsx file.(type of file 'ts')"