Skip to content

Instantly share code, notes, and snippets.

View puneetpunj's full-sized avatar
🏠
Working from home

Puneet Punj puneetpunj

🏠
Working from home
View GitHub Profile
@puneetpunj
puneetpunj / updated-execute-tests.js
Created March 31, 2020 10:43
add mssql tests to execute tests
const { runMochaTests } = require('./lib/mocha-setup');
const { defineTestSuiteAndAddTests } = require('./programmatic/sample-tests');
const { defineDBTestSuiteAndAddTests } = require('./programmatic/db-test');
(async () => {
defineTestSuiteAndAddTests();
await defineDBTestSuiteAndAddTests();
try {
@puneetpunj
puneetpunj / db-test.js
Last active March 31, 2020 10:44
mssql-db test case
const { suite, Test } = require('../lib/mocha-setup')
const { sendSQLServerQuery } = require('../lib/db-connect')
const expect = require('chai').expect;
const reportValue = require('mochawesome/addContext');
const defineDBTestSuiteAndAddTests = async () => {
const parentSuiteName = suite('sql server database test')
await validatedbData(parentSuiteName);
}
@puneetpunj
puneetpunj / db-connect.js
Created March 31, 2020 10:35
package to connect to mssql database
const sql = require("mssql");
const sendSQLServerQuery = async (query) => {
const config = {
user: 'sa',
password: 'Stupipassword123!',
server: 'localhost',
port: 60666,
database: 'TutorialDB',
options: {
@puneetpunj
puneetpunj / Dockerfile
Last active March 31, 2020 11:40
dockerfile to create new mssql server
FROM microsoft/mssql-server-linux:latest
ENV ACCEPT_EULA=Y
# update password
ENV SA_PASSWORD=Strongpassword123!
const { runMochaTests } = require('./lib/mocha-setup');
const { defineTestSuiteAndAddTests } = require('./programmatic/sample-tests');
(async () => {
defineTestSuiteAndAddTests();
try {
const result = await runMochaTests()
const { suite, Test, suiteInstance } = require('../lib/mocha-setup')
const expect = require('chai').expect;
const reportValue = require('mochawesome/addContext')
const defineTestSuiteAndAddTests = () => {
const parentSuiteName = suite('sample test suite')
comparisonWithNumber10Tests(parentSuiteName);
stringValidationTests(parentSuiteName);
testUnderParentSuite(parentSuiteName)
}
const Mocha = require('mocha');
const moment = require('moment-timezone');
const path = require('path')
// for reporting
const currentDateTime = moment().tz('Australia/Sydney').format('YYYY/MM/DD/HH:mm:ss');
const reportDirectory = path.resolve(__dirname, `../execution-report/${currentDateTime}`)
// mocha setup
const Test = Mocha.Test;
FROM cypress/browsers:chrome67
# COPY package.json .
RUN mkdir -p mnt
COPY . mnt/
RUN cd mnt && npm i cypress
RUN cd mnt && npm i
@puneetpunj
puneetpunj / cy-runner.sh
Created March 25, 2020 01:13
cy-runner and cypress.json after adding dashboard
# remove --spec all tests need to be executed
npx cypress run --record --key 628bbf4f-987a-44a2-83dc-a5f690b1bf60 --spec "cypress/integration/examples/location.spec.js,cypress/integration/examples/aliasing.spec.js"
#create new folder to store final report
mkdir -p execution-report
# merge all reports from repport folder and generate one json file
npx mochawesome-merge --reportDir reports/mochawesome-report > execution-report/report.json
# generate .html file from it and save it as detailed-report-<current timestamp>
# remove --spec all tests need to be executed
npx cypress run --spec "cypress/integration/examples/location.spec.js,cypress/integration/examples/aliasing.spec.js"
#create new folder to store final report
mkdir -p execution-report
# merge all reports from repport folder and generate one json file
npx mochawesome-merge --reportDir reports/mochawesome-report > execution-report/report.json
# generate .html file from it and save it as detailed-report-<current timestamp>