codi-test-framework
Advanced tools
Comparing version 1.0.16 to 1.0.17
@@ -433,3 +433,3 @@ var __defProp = Object.defineProperty; | ||
// src/_codi.js | ||
var version = "v1.0.16"; | ||
var version = "v1.0.17"; | ||
var codi = { | ||
@@ -436,0 +436,0 @@ describe, |
#!/usr/bin/env bun | ||
import { runCodi } from "./src/testRunner.js"; | ||
import { runCodi } from './src/testRunner.js'; | ||
await runCodi(); | ||
await runCodi(); |
@@ -1,11 +0,23 @@ | ||
import * as esbuild from 'esbuild'; | ||
import * as esbuild from "esbuild"; | ||
// Browser build | ||
await esbuild.build({ | ||
entryPoints: ['./src/_codi.js'], | ||
bundle: true, | ||
outfile: 'browser.js', | ||
format: 'esm', | ||
platform: 'browser', | ||
target: ['es2020'], | ||
external: ['chalk', 'figlet'] | ||
}); | ||
entryPoints: ["./src/_codi.js"], | ||
bundle: true, | ||
outfile: "browser.js", | ||
format: "esm", | ||
platform: "browser", | ||
target: ["es2020"], | ||
external: ["chalk", "figlet"], | ||
}); | ||
// CLI/Node.js build | ||
await esbuild.build({ | ||
entryPoints: ["./src/_codi.js"], | ||
bundle: true, | ||
outfile: "codi_node.js", | ||
format: "cjs", // Changed to CommonJS for Node.js | ||
platform: "node", // Changed to node | ||
target: ["node14"], // Target Node.js version | ||
external: ["chalk", "figlet"], | ||
}); |
{ | ||
"name": "codi-test-framework", | ||
"version": "1.0.16", | ||
"description": "A simple test framework for JavaScript", | ||
"type": "module", | ||
"exports": { | ||
".": "./browser.js" | ||
}, | ||
"main": "src/testRunner.js", | ||
"module": "./dist/web.js", | ||
"bin": { | ||
"codi": "cli.js" | ||
}, | ||
"scripts": { | ||
"build": "node esbuild.config.js", | ||
"test": "bun --bun cli.js tests --returnResults", | ||
"test_web": "bun --bun ./tests/webfunction.js", | ||
"version": "bun --bun cli.js --version", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
"keywords": [ | ||
"test", | ||
"framework", | ||
"javascript" | ||
], | ||
"author": "Rob Hurst", | ||
"license": "MIT", | ||
"dependencies": { | ||
"chalk": "^5.3.0", | ||
"figlet": "^1.7.0" | ||
}, | ||
"devDependencies": { | ||
"esbuild": "^0.19.11" | ||
"name": "codi-test-framework", | ||
"version": "1.0.17", | ||
"description": "A simple test framework for JavaScript", | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"browser": "./browser.js", | ||
"node": "./codi_node.js", | ||
"default": "./codi_node.js" | ||
} | ||
}, | ||
"main": "src/testRunner.js", | ||
"module": "./dist/web.js", | ||
"bin": { | ||
"codi": "cli.js" | ||
}, | ||
"scripts": { | ||
"build": "node esbuild.config.js", | ||
"test": "bun --bun cli.js tests --returnResults", | ||
"test_web": "bun --bun ./tests/webfunction.js", | ||
"version": "bun --bun cli.js --version", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
"keywords": [ | ||
"test", | ||
"framework", | ||
"javascript" | ||
], | ||
"author": "Rob Hurst", | ||
"license": "MIT", | ||
"dependencies": { | ||
"chalk": "^5.3.0", | ||
"figlet": "^1.7.0" | ||
}, | ||
"devDependencies": { | ||
"codi-test-framework": "^1.0.16", | ||
"esbuild": "^0.19.11" | ||
} | ||
} |
import assertions from "./assertions/_assertions.js"; | ||
import { describe } from './core/describe.js'; | ||
import { it } from './core/it.js'; | ||
import { state } from './state/TestState.js'; | ||
import { describe } from "./core/describe.js"; | ||
import { it } from "./core/it.js"; | ||
import { state } from "./state/TestState.js"; | ||
import { | ||
runWebTests, | ||
runWebTestFile, | ||
runWebTestFunction | ||
} from './runners/webRunner.js'; | ||
runWebTests, | ||
runWebTestFile, | ||
runWebTestFunction, | ||
} from "./runners/webRunner.js"; | ||
import { codepenLogging } from "./codepen/logging.js"; | ||
const version = 'v1.0.16'; | ||
const version = "v1.0.17"; | ||
// Create the codi object to hold all exports | ||
const codi = { | ||
describe, | ||
it, | ||
state, | ||
runWebTests, | ||
runWebTestFile, | ||
runWebTestFunction, | ||
assertEqual: assertions.assertEqual, | ||
assertNotEqual: assertions.assertNotEqual, | ||
assertTrue: assertions.assertTrue, | ||
assertFalse: assertions.assertFalse, | ||
assertThrows: assertions.assertThrows, | ||
assertNoDuplicates: assertions.assertNoDuplicates, | ||
version, | ||
codepenLogging | ||
describe, | ||
it, | ||
state, | ||
runWebTests, | ||
runWebTestFile, | ||
runWebTestFunction, | ||
assertEqual: assertions.assertEqual, | ||
assertNotEqual: assertions.assertNotEqual, | ||
assertTrue: assertions.assertTrue, | ||
assertFalse: assertions.assertFalse, | ||
assertThrows: assertions.assertThrows, | ||
assertNoDuplicates: assertions.assertNoDuplicates, | ||
version, | ||
codepenLogging, | ||
}; | ||
@@ -38,22 +38,22 @@ | ||
export { | ||
describe, | ||
it, | ||
state, | ||
runWebTests, | ||
runWebTestFile, | ||
runWebTestFunction, | ||
version, | ||
codepenLogging | ||
describe, | ||
it, | ||
state, | ||
runWebTests, | ||
runWebTestFile, | ||
runWebTestFunction, | ||
version, | ||
codepenLogging, | ||
}; | ||
export const { | ||
assertEqual, | ||
assertNotEqual, | ||
assertTrue, | ||
assertFalse, | ||
assertThrows, | ||
assertNoDuplicates | ||
assertEqual, | ||
assertNotEqual, | ||
assertTrue, | ||
assertFalse, | ||
assertThrows, | ||
assertNoDuplicates, | ||
} = assertions; | ||
// Export the entire codi object as default | ||
export default codi; | ||
export default codi; |
// Import and run tests | ||
import * as codi from 'https://esm.sh/codi-test-framework@1.0.15'; | ||
import * as codi from "https://esm.sh/codi-test-framework@1.0.16"; | ||
codi.codepenLogging(); | ||
function describeExample() { | ||
codi.describe({ name: "I am a test suite", id: "test_suite" }, () => { | ||
codi.it( | ||
{ name: "example test", id: "my first test", parentId: "test_suite" }, | ||
() => { | ||
codi.assertEqual(1, 1, "We expect the number 1 to equal the number 1"); | ||
}, | ||
); | ||
}); | ||
} | ||
await codi.runWebTestFunction(describeExample, { | ||
quiet: false, | ||
showSummary: true, | ||
}); | ||
// Main test execution | ||
await codi.runWebTestFunction(async () => { | ||
await codi.runWebTestFunction( | ||
async () => { | ||
// Sequential setup tests | ||
@@ -12,28 +28,28 @@ await setupTests(); | ||
// Parallel test batches | ||
await Promise.all([ | ||
batchOne(), | ||
batchTwo(), | ||
batchThree(), | ||
batchFour() | ||
]); | ||
}, { | ||
await Promise.all([batchOne(), batchTwo(), batchThree(), batchFour()]); | ||
}, | ||
{ | ||
quiet: false, // Changed to false to ensure output | ||
showSummary: true | ||
}); | ||
showSummary: true, | ||
}, | ||
); | ||
// Sequential setup tests | ||
async function setupTests() { | ||
codi.describe({ name: 'Setup Tests', id: 'setup' }, async () => { | ||
codi.it({ name: 'Should initilise setup', parentId: 'setup' }, async () => { | ||
await simulateDelay(250); | ||
codi.assertEqual(true, true, 'Workspace initialized'); | ||
console.log('Test 1') | ||
}); | ||
codi.describe({ name: "Setup Tests", id: "setup" }, async () => { | ||
codi.it({ name: "Should initilise setup", parentId: "setup" }, async () => { | ||
await simulateDelay(250); | ||
codi.assertEqual(true, true, "Workspace initialized"); | ||
console.log("Test 1"); | ||
}); | ||
codi.it({ name: 'Should do some more setup', parentId: 'setup' }, async () => { | ||
await simulateDelay(150); | ||
codi.assertEqual(true, true, 'Query system ready'); | ||
console.log('Test 2') | ||
}); | ||
}); | ||
codi.it( | ||
{ name: "Should do some more setup", parentId: "setup" }, | ||
async () => { | ||
await simulateDelay(150); | ||
codi.assertEqual(true, true, "Query system ready"); | ||
console.log("Test 2"); | ||
}, | ||
); | ||
}); | ||
} | ||
@@ -43,21 +59,21 @@ | ||
async function batchOne() { | ||
codi.describe({ name: 'batch_1', id: '1' }, async () => { | ||
await Promise.all([ | ||
codi.it({ name: 'Test 1.1', parentId: '1' }, async () => { | ||
await simulateDelay(100); | ||
codi.assertEqual(true, true, 'Test 1.1 passed'); | ||
console.log('Test 4') | ||
}), | ||
codi.it({ name: 'Test 1.2', parentId: '1' }, async () => { | ||
await simulateDelay(75); | ||
codi.assertEqual(true, true, 'Test 1.2 passed'); | ||
console.log('Test 5') | ||
}), | ||
codi.it({ name: 'Test 1.3', parentId: '1' }, async () => { | ||
await simulateDelay(50); | ||
codi.assertEqual(false, false, 'Test 1.3 passed'); | ||
console.log('Test 6') | ||
}) | ||
]); | ||
}); | ||
codi.describe({ name: "batch_1", id: "1" }, async () => { | ||
await Promise.all([ | ||
codi.it({ name: "Test 1.1", parentId: "1" }, async () => { | ||
await simulateDelay(100); | ||
codi.assertEqual(true, true, "Test 1.1 passed"); | ||
console.log("Test 4"); | ||
}), | ||
codi.it({ name: "Test 1.2", parentId: "1" }, async () => { | ||
await simulateDelay(75); | ||
codi.assertEqual(true, true, "Test 1.2 passed"); | ||
console.log("Test 5"); | ||
}), | ||
codi.it({ name: "Test 1.3", parentId: "1" }, async () => { | ||
await simulateDelay(50); | ||
codi.assertEqual(false, false, "Test 1.3 passed"); | ||
console.log("Test 6"); | ||
}), | ||
]); | ||
}); | ||
} | ||
@@ -67,21 +83,21 @@ | ||
async function batchTwo() { | ||
codi.describe({ name: 'batch_2', id: '2', parentId: '1' }, async () => { | ||
Promise.all([ | ||
codi.it({ name: 'Test 2.1', parentId: '2' }, async () => { | ||
await simulateDelay(125); | ||
codi.assertEqual(true, true, 'Test 2.1 passed'); | ||
console.log('Test 7') | ||
}), | ||
codi.it({ name: 'Test 2.2', parentId: '2' }, async () => { | ||
await simulateDelay(150); | ||
codi.assertEqual(1, 2, 'This test should fail'); | ||
console.log('Test 8') | ||
}), | ||
codi.it({ name: 'Test 2.3', parentId: '2' }, async () => { | ||
await simulateDelay(175); | ||
codi.assertEqual(true, true, 'Test 2.3 passed'); | ||
console.log('Test 9') | ||
}) | ||
]); | ||
}); | ||
codi.describe({ name: "batch_2", id: "2", parentId: "1" }, async () => { | ||
Promise.all([ | ||
codi.it({ name: "Test 2.1", parentId: "2" }, async () => { | ||
await simulateDelay(125); | ||
codi.assertEqual(true, true, "Test 2.1 passed"); | ||
console.log("Test 7"); | ||
}), | ||
codi.it({ name: "Test 2.2", parentId: "2" }, async () => { | ||
await simulateDelay(150); | ||
codi.assertEqual(1, 2, "This test should fail"); | ||
console.log("Test 8"); | ||
}), | ||
codi.it({ name: "Test 2.3", parentId: "2" }, async () => { | ||
await simulateDelay(175); | ||
codi.assertEqual(true, true, "Test 2.3 passed"); | ||
console.log("Test 9"); | ||
}), | ||
]); | ||
}); | ||
} | ||
@@ -91,47 +107,47 @@ | ||
async function batchThree() { | ||
codi.describe({ name: 'batch_3', id: '3', parentId: '2' }, async () => { | ||
await Promise.all([ | ||
codi.it({ name: 'Test 3.1', parentId: '3' }, async () => { | ||
await simulateDelay(200); | ||
codi.assertEqual(true, true, 'Test 3.1 passed'); | ||
console.log('Test 10') | ||
}), | ||
codi.it({ name: 'Test 3.2', parentId: '3' }, async () => { | ||
await simulateDelay(225); | ||
codi.assertEqual(true, true, 'Test 4.2 passed'); | ||
console.log('Test 11') | ||
}), | ||
codi.it({ name: 'Test 3.3', parentId: '3' }, async () => { | ||
await simulateDelay(250); | ||
codi.assertEqual({ a: 1 }, { a: 1 }, 'Test 3.3 passed'); | ||
console.log('Test 12') | ||
}) | ||
]); | ||
}); | ||
codi.describe({ name: "batch_3", id: "3", parentId: "2" }, async () => { | ||
await Promise.all([ | ||
codi.it({ name: "Test 3.1", parentId: "3" }, async () => { | ||
await simulateDelay(200); | ||
codi.assertEqual(true, true, "Test 3.1 passed"); | ||
console.log("Test 10"); | ||
}), | ||
codi.it({ name: "Test 3.2", parentId: "3" }, async () => { | ||
await simulateDelay(225); | ||
codi.assertEqual(true, true, "Test 4.2 passed"); | ||
console.log("Test 11"); | ||
}), | ||
codi.it({ name: "Test 3.3", parentId: "3" }, async () => { | ||
await simulateDelay(250); | ||
codi.assertEqual({ a: 1 }, { a: 1 }, "Test 3.3 passed"); | ||
console.log("Test 12"); | ||
}), | ||
]); | ||
}); | ||
} | ||
async function batchFour() { | ||
codi.describe({ name: 'batch_4', id: '4', parentId: '3' }, async () => { | ||
await Promise.all([ | ||
codi.it({ name: 'Test 4.1', parentId: '4' }, async () => { | ||
await simulateDelay(900); | ||
codi.assertEqual(true, true, 'Test 4.1 passed'); | ||
console.log('Test 13') | ||
}), | ||
codi.it({ name: 'Test 4.2', parentId: '4' }, async () => { | ||
await simulateDelay(3600); | ||
codi.assertEqual(true, true, 'Test 4.2 passed'); | ||
console.log('Test 14') | ||
}), | ||
codi.it({ name: 'Test 4.3', parentId: '4' }, async () => { | ||
await simulateDelay(500); | ||
codi.assertEqual({ a: 1 }, { a: 2 }, 'Test 4.3 failed'); | ||
console.log('Test 15') | ||
}) | ||
]); | ||
}); | ||
codi.describe({ name: "batch_4", id: "4", parentId: "3" }, async () => { | ||
await Promise.all([ | ||
codi.it({ name: "Test 4.1", parentId: "4" }, async () => { | ||
await simulateDelay(900); | ||
codi.assertEqual(true, true, "Test 4.1 passed"); | ||
console.log("Test 13"); | ||
}), | ||
codi.it({ name: "Test 4.2", parentId: "4" }, async () => { | ||
await simulateDelay(3600); | ||
codi.assertEqual(true, true, "Test 4.2 passed"); | ||
console.log("Test 14"); | ||
}), | ||
codi.it({ name: "Test 4.3", parentId: "4" }, async () => { | ||
await simulateDelay(500); | ||
codi.assertEqual({ a: 1 }, { a: 2 }, "Test 4.3 failed"); | ||
console.log("Test 15"); | ||
}), | ||
]); | ||
}); | ||
} | ||
function simulateDelay(ms) { | ||
return new Promise(resolve => setTimeout(resolve, ms)); | ||
} | ||
return new Promise((resolve) => setTimeout(resolve, ms)); | ||
} |
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
72757
33
2074
2