Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

codeceptjs

Package Overview
Dependencies
Maintainers
4
Versions
235
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

codeceptjs - npm Package Compare versions

Comparing version 3.5.14 to 3.5.15

55

lib/command/dryRun.js

@@ -62,20 +62,35 @@ const { getConfig, getTestRoot } = require('./utils');

let numOfSuites = 0;
const filteredSuites = [];
let outputString = '';
const filterBy = process.env.grep ? process.env.grep.toLowerCase() : undefined;
for (const suite of mocha.suite.suites) {
if (process.env.grep && suite.title.toLowerCase().includes(process.env.grep)) {
filteredSuites.push(suite);
if (filterBy) {
for (const suite of mocha.suite.suites) {
const currentSuite = suite.title;
if (suite.title.toLowerCase().includes(filterBy)) {
outputString += `${colors.white.bold(suite.title)} -- ${output.styles.log(suite.file || '')} -- ${mocha.suite.suites.length} tests\n`;
numOfSuites++;
}
for (test of suite.tests) {
if (test.title.toLowerCase().includes(filterBy)) {
numOfTests++;
outputString += `${colors.white.bold(test.parent.title)} -- ${output.styles.log(test.parent.file || '')} -- ${mocha.suite.suites.length} tests\n`;
outputString += ` ${output.styles.scenario(figures.checkboxOff)} ${test.title}\n`;
}
}
}
}
const displayedSuites = process.env.grep ? filteredSuites : mocha.suite.suites;
for (const suite of displayedSuites) {
output.print(`${colors.white.bold(suite.title)} -- ${output.styles.log(suite.file || '')} -- ${suite.tests.length} tests`);
numOfSuites++;
numOfSuites = countSuites(outputString);
} else {
for (const suite of mocha.suite.suites) {
output.print(`${colors.white.bold(suite.title)} -- ${output.styles.log(suite.file || '')} -- ${mocha.suite.suites.length} tests`);
numOfSuites++;
for (const test of suite.tests) {
numOfTests++;
output.print(` ${output.styles.scenario(figures.checkboxOff)} ${test.title}`);
for (test of suite.tests) {
numOfTests++;
output.print(` ${output.styles.scenario(figures.checkboxOff)} ${test.title}`);
}
}
}
output.print(removeDuplicates(outputString));
output.print('');

@@ -91,1 +106,17 @@ output.success(` Total: ${numOfSuites} suites | ${numOfTests} tests `);

}
function removeDuplicates(inputString) {
const array = inputString.split('\n');
const uniqueLines = [...new Set(array)];
const resultString = uniqueLines.join('\n');
return resultString;
}
function countSuites(inputString) {
const array = inputString.split('\n');
const uniqueLines = [...new Set(array)];
const res = uniqueLines.filter(item => item.includes('-- '));
return res.length;
}

@@ -193,3 +193,3 @@ const output = require('../output');

* @param {*} [customErrorMsg]
* @param {*} ajvOptions Pass AJV options
* @param {*} [ajvOptions] Pass AJV options
*/

@@ -196,0 +196,0 @@ expectJsonSchemaUsingAJV(

const debugModule = require('debug');
const fs = require('fs');
const path = require('path');
const { CoverageReport } = require('monocart-coverage-reports');
const Container = require('../container');

@@ -9,7 +7,7 @@ const recorder = require('../recorder');

const output = require('../output');
const { clearString } = require('../utils');
const { deepMerge } = require('../utils');
const defaultConfig = {
coverageDir: 'output/coverage',
uniqueFileName: true,
name: 'CodeceptJS Coverage Report',
outputDir: 'output/coverage',
};

@@ -19,27 +17,52 @@

function buildFileName(test, uniqueFileName) {
let fileName = clearString(test.title);
const v8CoverageHelpers = {
Playwright: {
startCoverage: async (page) => {
await Promise.all([
page.coverage.startJSCoverage({
resetOnNavigation: false,
}),
page.coverage.startCSSCoverage({
resetOnNavigation: false,
}),
]);
},
takeCoverage: async (page, coverageReport) => {
const [jsCoverage, cssCoverage] = await Promise.all([
page.coverage.stopJSCoverage(),
page.coverage.stopCSSCoverage(),
]);
const coverageList = [...jsCoverage, ...cssCoverage];
await coverageReport.add(coverageList);
},
},
Puppeteer: {
startCoverage: async (page) => {
await Promise.all([
page.coverage.startJSCoverage({
resetOnNavigation: false,
includeRawScriptCoverage: true,
}),
page.coverage.startCSSCoverage({
resetOnNavigation: false,
}),
]);
},
takeCoverage: async (page, coverageReport) => {
const [jsCoverage, cssCoverage] = await Promise.all([
page.coverage.stopJSCoverage(),
page.coverage.stopCSSCoverage(),
]);
// to raw V8 script coverage
const coverageList = [...jsCoverage.map((it) => {
return {
source: it.text,
...it.rawScriptCoverage,
};
}), ...cssCoverage];
await coverageReport.add(coverageList);
},
},
};
// This prevent data driven to be included in the failed screenshot file name
if (fileName.indexOf('{') !== -1) {
fileName = fileName.substr(0, fileName.indexOf('{') - 3).trim();
}
if (test.ctx && test.ctx.test && test.ctx.test.type === 'hook') {
fileName = clearString(`${test.title}_${test.ctx.test.title}`);
}
if (uniqueFileName) {
const uuid = test.uuid
|| test.ctx.test.uuid
|| Math.floor(new Date().getTime() / 1000);
fileName = `${fileName.substring(0, 10)}_${uuid}.coverage.json`;
} else {
fileName = `${fileName}.coverage.json`;
}
return fileName;
}
/**

@@ -54,3 +77,6 @@ * Dumps code coverage from Playwright/Puppeteer after every test.

* coverage: {
* enabled: true
* enabled: true,
* debug: true,
* name: 'CodeceptJS Coverage Report',
* outputDir: 'output/coverage'
* }

@@ -60,87 +86,74 @@ * }

*
* Possible config options:
* Possible config options, More could be found at [monocart-coverage-reports](https://github.com/cenfun/monocart-coverage-reports?tab=readme-ov-file#default-options)
*
* * `coverageDir`: directory to dump coverage files
* * `uniqueFileName`: generate a unique filename by adding uuid
* * `debug`: debug info. By default, false.
* * `name`: coverage report name.
* * `outputDir`: path to coverage report.
* * `sourceFilter`: filter the source files.
* * `sourcePath`: option to resolve a custom path.
*
*/
module.exports = function (config) {
config = deepMerge(defaultConfig, config);
if (config.debug) config.logging = 'debug';
const helpers = Container.helpers();
let coverageRunning = false;
let helper;
let debug;
for (const helperName of supportedHelpers) {
if (Object.keys(helpers).indexOf(helperName) > -1) {
helper = helpers[helperName];
debug = debugModule(`codeceptjs:plugin:${helperName.toLowerCase()}Coverage`);
}
const v8Names = Object.keys(v8CoverageHelpers);
const helperName = Object.keys(helpers).find((it) => v8Names.includes(it));
if (!helperName) {
console.error(`Coverage is only supported in ${supportedHelpers.join(' or ')}`);
// no helpers for screenshot
return;
}
if (!helper) {
console.error('Coverage is only supported in Puppeteer, Playwright');
return; // no helpers for screenshot
}
config.name = `${config.name} - in ${helperName}`;
const debug = debugModule(`codeceptjs:plugin:${helperName.toLowerCase()}Coverage`);
const options = Object.assign(defaultConfig, helper.options, config);
const helper = helpers[helperName];
const v8Helper = v8CoverageHelpers[helperName];
event.dispatcher.on(event.all.before, async () => {
output.debug('*** Collecting coverage for tests ****');
const coverageOptions = {
...config,
};
const coverageReport = new CoverageReport(coverageOptions);
coverageReport.cleanCache();
event.dispatcher.on(event.all.after, async () => {
output.print(`writing ${coverageOptions.outputDir}`);
await coverageReport.generate();
});
// Hack! we're going to try to "start" coverage before each step because this is
// we're going to try to "start" coverage before each step because this is
// when the browser is already up and is ready to start coverage.
event.dispatcher.on(event.step.before, async () => {
recorder.add(
'starting coverage',
async () => {
try {
if (!coverageRunning && helper.page && helper.page.coverage) {
debug('--> starting coverage <--');
coverageRunning = true;
await helper.page.coverage.startJSCoverage();
}
} catch (err) {
console.error(err);
}
},
true,
);
event.dispatcher.on(event.step.before, () => {
recorder.add('start coverage', async () => {
if (coverageRunning) {
return;
}
if (!helper.page || !helper.page.coverage) {
return;
}
coverageRunning = true;
debug('--> starting coverage <--');
await v8Helper.startCoverage(helper.page);
}, true);
});
// Save coverage data after every test run
event.dispatcher.on(event.test.after, async (test) => {
recorder.add(
'saving coverage',
async () => {
try {
if (coverageRunning && helper.page && helper.page.coverage) {
debug('--> stopping coverage <--');
coverageRunning = false;
const coverage = await helper.page.coverage.stopJSCoverage();
const coverageDir = path.resolve(
process.cwd(),
options.coverageDir,
);
// Checking if coverageDir already exists, if not, create new one
if (!fs.existsSync(coverageDir)) {
fs.mkdirSync(coverageDir, { recursive: true });
}
const coveragePath = path.resolve(
coverageDir,
buildFileName(test, options.uniqueFileName),
);
output.print(`writing ${coveragePath}`);
fs.writeFileSync(coveragePath, JSON.stringify(coverage));
}
} catch (err) {
console.error(err);
}
},
true,
);
event.dispatcher.on(event.test.after, (test) => {
recorder.add('take coverage', async () => {
if (!coverageRunning) {
return;
}
if (!helper.page || !helper.page.coverage) {
return;
}
coverageRunning = false;
debug('--> stopping coverage <--');
await v8Helper.takeCoverage(helper.page, coverageReport);
}, true);
});
};
{
"name": "codeceptjs",
"version": "3.5.14",
"version": "3.5.15",
"description": "Supercharged End 2 End Testing Framework for NodeJS",

@@ -32,3 +32,3 @@ "keywords": [

"main": "lib/index.js",
"typings": "typings/index.d.ts",
"types": "typings/index.d.ts",
"bin": {

@@ -66,3 +66,4 @@ "codeceptjs": "./bin/codecept.js"

"update-contributor-faces": "./runok.js contributor:faces",
"dtslint": "dtslint typings --localTs './node_modules/typescript/lib'",
"types-fix": "node typings/fixDefFiles.js",
"dtslint": "npm run types-fix && tsd",
"prepare": "husky install",

@@ -72,3 +73,3 @@ "prepare-release": "./runok.js versioning && ./runok.js get:commit-log"

"dependencies": {
"@codeceptjs/configure": "0.10.0",
"@codeceptjs/configure": "1.0.1",
"@codeceptjs/helper": "2.0.1",

@@ -82,3 +83,3 @@ "@cucumber/cucumber-expressions": "17",

"axios": "1.6.7",
"chai": "5.0.3",
"chai": "5.1.0",
"chai-deep-match": "1.2.1",

@@ -95,3 +96,3 @@ "chai-exclude": "2.1.0",

"csstoxpath": "1.6.0",
"devtools": "8.29.1",
"devtools": "8.33.1",
"envinfo": "7.11.0",

@@ -105,12 +106,13 @@ "escape-string-regexp": "4.0.0",

"inquirer": "6.5.2",
"joi": "17.12.1",
"js-beautify": "1.14.11",
"joi": "17.12.2",
"js-beautify": "1.15.1",
"lodash.clonedeep": "4.5.0",
"lodash.merge": "4.6.2",
"mkdirp": "1.0.4",
"mocha": "10.2.0",
"mocha": "10.3.0",
"monocart-coverage-reports": "2.7.1",
"ms": "2.1.3",
"openai": "3.2.1",
"ora-classic": "5.4.2",
"pactum": "3.6.0",
"pactum": "3.6.1",
"parse-function": "5.6.10",

@@ -124,3 +126,3 @@ "parse5": "7.1.2",

"optionalDependencies": {
"@codeceptjs/detox-helper": "1.0.2"
"@codeceptjs/detox-helper": "1.0.5"
},

@@ -135,3 +137,3 @@ "devDependencies": {

"@types/node": "20.11.16",
"@wdio/sauce-service": "8.29.1",
"@wdio/sauce-service": "8.32.3",
"@wdio/selenium-standalone-service": "8.3.2",

@@ -145,3 +147,2 @@ "@wdio/utils": "8.28.8",

"documentation": "12.3.0",
"dtslint": "4.2.1",
"electron": "28.2.1",

@@ -153,3 +154,3 @@ "eslint": "8.56.0",

"expect": "29.7.0",
"express": "4.18.2",
"express": "4.18.3",
"graphql": "14.6.0",

@@ -162,3 +163,3 @@ "husky": "8.0.3",

"playwright": "1.41.1",
"puppeteer": "21.1.1",
"puppeteer": "22.4.1",
"qrcode-terminal": "0.12.0",

@@ -172,8 +173,9 @@ "rosie": "2.1.1",

"ts-node": "10.9.2",
"tsd": "^0.30.7",
"tsd-jsdoc": "2.5.0",
"typedoc": "0.25.7",
"typedoc": "0.25.12",
"typedoc-plugin-markdown": "3.17.1",
"typescript": "5.3.3",
"wdio-docker-service": "1.5.0",
"webdriverio": "8.31.1",
"webdriverio": "8.33.1",
"xml2js": "0.6.2",

@@ -186,3 +188,9 @@ "xpath": "0.0.34"

},
"es6": true
}
"es6": true,
"tsd": {
"directory": "typings",
"compilerOptions": {
"strict": false
}
}
}

@@ -11,2 +11,3 @@ // Project: https://github.com/codeception/codeceptjs/

type WithTranslation<T> = T &
// @ts-ignore
import("./utils").Translate<T, Translation.Actions>;

@@ -13,0 +14,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc