New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

codi-test-framework

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

codi-test-framework - npm Package Compare versions

Comparing version 0.0.23 to 0.0.24

5

package.json
{
"name": "codi-test-framework",
"version": "0.0.23",
"version": "0.0.24",
"description": "A simple test framework for JavaScript",

@@ -11,3 +11,4 @@ "main": "src/testRunner.js",

"scripts": {
"test": "bun cli.js tests --bun"
"test": "bun --bun cli.js tests --returnResults",
"version": "bun --bun cli.js --version"
},

@@ -14,0 +15,0 @@ "keywords": [

51

src/testRunner.js

@@ -12,9 +12,14 @@ import fs from 'fs';

export const assertThrows = assertions.assertThrows;
export const assertDeepEqual = assertions.assertDeepEqual;
let passedTests = 0;
let failedTests = 0;
let testResults = [];
let version = 'v0.0.24';
export async function describe(description, callback) {
console.log(chalk.bold.cyan(`\n${description}`));
const describe = {
[description]: []
}
testResults.push(describe);
await callback();

@@ -24,11 +29,21 @@ }

export async function it(description, callback) {
const itObj = {
[description]: []
}
const currentDescribeObj = testResults[testResults.length - 1];
try {
await callback();
console.log(chalk.green(` ✅ ${description}`));
console.log(chalk.green(` ✅ ${description}`));
itObj[description] = 'passed';
passedTests++;
} catch (error) {
console.error(chalk.red(` ⛔ ${description}`));
console.error(chalk.red(` ${error.message}`));
console.error(chalk.red(` ⛔ ${description}`));
console.error(chalk.red(` ${error.message}`));
itObj[description] = 'failed';
failedTests++;
}
Object.values(currentDescribeObj)[0].push(itObj);
}

@@ -54,3 +69,3 @@

// Function to run all test files in a directory
export async function runTests(testDirectory) {
export async function runTests(testDirectory, returnResults = false) {
// Read all files in the test directory

@@ -73,2 +88,13 @@ const testFiles = fs.readdirSync(testDirectory, { recursive: true }).filter(file => file.endsWith('.mjs'));

if (returnResults) {
let results = {
passedTests,
failedTests,
testResults
};
return results;
}
// Exit the process with the appropriate status code

@@ -108,2 +134,7 @@ if (failedTests > 0) {

return {
passedTests,
failedTests,
testResults
}
}

@@ -114,3 +145,10 @@

const testDirectory = process.argv[2];
const returnResults = process.argv.includes('--returnResults');
const returnVersion = process.argv.includes('--version');
if (returnVersion) {
console.log(chalk.blue(version));
process.exit(0);
}
if (!testDirectory) {

@@ -125,3 +163,4 @@ console.error(chalk.red('Please provide a test directory as an argument.'));

runTests(testDirectory);
runTests(testDirectory, returnResults);
}
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