ToolJet/cypress-tests/cypress.config.js
Midhun Kumar E 06cc6ece9d
Added code coverage for cypress (#8234)
* Frontend: Add new plugin babel-plugin-istanbul

* Frontend: Add plugin to babel config

* Cypress: Add new plugin code-coverage

* Cypress: Add plugin to common  cypress suite

* Cypress: Add reports to .gitignore

* Actions: Add new action to check coverage

* Cypress: minor config changes

* test

* test-2

* Action: Add verification for generated coverage files

* Modify action file

* Modify action file with command changes

* debug commit

* debug commit-2

* debug commit-3

* Update runjsHappyPath.cy.js

* debug commit-4

* Revert "debug commit-5"

This reverts commit 8b795d86ae.

* Revert "debug commit-3"

This reverts commit d2e440e04b.

* Add action name

* Fix marketplace specs

* Fix query failures

* Add review changes

* Add cypress package.lock changes

* Add frontend package.lock changes

* Add cypress minor  package.lock changes

* Minor action changes
2023-12-28 15:16:16 +05:30

113 lines
3.3 KiB
JavaScript

const { defineConfig } = require("cypress");
const { rmdir } = require("fs");
const fs = require("fs");
const XLSX = require("node-xlsx");
const pg = require("pg");
const path = require("path");
const pdf = require("pdf-parse");
module.exports = defineConfig({
execTimeout: 1800000,
defaultCommandTimeout: 30000,
requestTimeout: 10000,
pageLoadTimeout: 20000,
responseTimeout: 10000,
viewportWidth: 1440,
viewportHeight: 960,
chromeWebSecurity: false,
trashAssetsBeforeRuns: true,
e2e: {
setupNodeEvents(on, config) {
on("task", {
readPdf(pathToPdf) {
return new Promise((resolve) => {
const pdfPath = path.resolve(pathToPdf);
let dataBuffer = fs.readFileSync(pdfPath);
pdf(dataBuffer).then(function ({ text }) {
resolve(text);
});
});
},
});
on("task", {
readXlsx(filePath) {
return new Promise((resolve, reject) => {
try {
let dataBuffer = fs.readFileSync(filePath);
const jsonData = XLSX.parse(dataBuffer);
// jsonData= jsonData[0].data
resolve(jsonData[0]["data"].toString());
} catch (e) {
reject(e);
}
});
},
});
on("task", {
deleteFolder(folderName) {
return new Promise((resolve, reject) => {
if (fs.existsSync(folderName)) {
rmdir(folderName, { maxRetries: 10, recursive: true }, (err) => {
if (err) {
console.error(err);
return reject(err);
}
return resolve(null);
});
} else {
return resolve(null);
}
});
},
});
on("task", {
updateId({ dbconfig, sql }) {
const client = new pg.Pool(dbconfig);
return client.query(sql);
},
});
require("@cypress/code-coverage/task")(on, config);
// return config;
require("./cypress/plugins/index.js")(on, config);
return config;
},
experimentalRunAllSpecs: true,
experimentalModfyObstructiveThirdPartyCode: true,
experimentalRunAllSpecs: true,
baseUrl: "http://localhost:8082",
specPattern: [
"cypress/e2e/workspace/*.cy.js",
"cypress/e2e/globalDataSources/*.cy.js",
"cypress/e2e/editor/app-version/version.cy.js",
"cypress/e2e/editor/widget/*.cy.js",
"cypress/e2e/editor/multipage/*.cy.js",
"cypress/e2e/editor/globalSetingsHappyPath.cy.js",
"cypress/e2e/editor/inspectorHappypath.cy.js",
"cypress/e2e/editor/queries/runpyHappyPath.cy.js",
"cypress/e2e/editor/queries/runjsHappyPath.cy.js",
"cypress/e2e/exportImport/export.cy.js",
"cypress/e2e/exportImport/import.cy.js",
"cypress/e2e/editor/data-source/*.cy.js",
"cypress/e2e/database/database.cy.js",
"cypress/e2e/selfHost/*.cy.js",
"cypress/e2e/authentication/*.cy.js",
],
downloadsFolder: "cypress/downloads",
numTestsKeptInMemory: 0,
redirectionLimit: 10,
experimentalRunAllSpecs: true,
trashAssetsBeforeRuns: true,
experimentalMemoryManagement: true,
coverage: true,
codeCoverageTasksRegistered: true,
video: false,
videoUploadOnPasses: false,
},
});