Skip to content

Commit

Permalink
Version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
RobAndrewHurst committed Nov 13, 2024
1 parent e1e88bf commit 70abc51
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 39 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codi-test-framework",
"version": "v0.0.44",
"version": "v0.0.45",
"description": "A simple test framework for JavaScript",
"main": "src/testRunner.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion src/runners/webRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export async function runWebTests(testFiles, options) {
state.resetCounters();
state.startTimer();

if (!quiet) {
if (!options.quiet) {
console.log(chalk.bold.magenta(`\nRunning ${testFiles.length} web test file(s)`));
}

Expand Down
2 changes: 1 addition & 1 deletion src/testRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const assertFalse = assertions.assertFalse;
export const assertThrows = assertions.assertThrows;
export const assertNoDuplicates = assertions.assertNoDuplicates;

export const version = 'v0.0.44';
export const version = 'v0.0.45';

/**
* CLI entry point for running tests
Expand Down
116 changes: 80 additions & 36 deletions tests/webfunction.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,97 @@
import { runWebTestFunction } from "../src/runners/webRunner.js";
import { describe, it, assertEqual, } from '../src/testRunner.js';
import { describe, it, assertEqual } from '../src/testRunner.js';

// Main test execution
await runWebTestFunction(async () => {
// Sequential setup tests
await setupTests();

await runWebTestFunction(testFunction, {
quiet: true,
// Parallel test batches
await Promise.all([
batchOne(),
batchTwo(),
batchThree()
]);
}, {
quiet: false,
showSummary: true
});

function testFunction() {
describe('First Layer', () => {
it('First', () => {
assertEqual(1, 2, 'Expected 1 to equal 1');
// Sequential setup tests
async function setupTests() {
await describe('Setup Tests', async () => {
await it('should initialize workspace', async () => {
await simulateDelay(100);
assertEqual(true, true, 'Workspace initialized');
});
it('Second', () => {
assertEqual(1, 1, 'Expected 1 to equal 1');
});
it('Third', () => {
assertEqual(1, 1, 'Expected 1 to equal 1');

await it('should setup query system', async () => {
await simulateDelay(150);
assertEqual(true, true, 'Query system ready');
});
});
}

secondFunction();
// Test batch 1
async function batchOne() {
await describe('First Batch', async () => {
await Promise.all([
it('Test 1.1', async () => {
await simulateDelay(100);
assertEqual(true, true, 'Test 1.1 passed');
}),
it('Test 1.2', async () => {
await simulateDelay(75);
assertEqual(true, true, 'Test 1.2 passed');
}),
it('Test 1.3', async () => {
await simulateDelay(50);
assertEqual(false, false, 'Test 1.3 passed');
})
]);
});
}

function secondFunction() {
describe('Second Layer', () => {
it('First', () => {
assertEqual(1, 1, 'Expected 1 to equal 1');
});
it('Second', () => {
assertEqual(1, 1, 'Expected 1 to equal 1');
});
it('Third', () => {
assertEqual(1, 1, 'Expected 1 to equal 1');
});
thirdFunction();
// Test batch 2
async function batchTwo() {
await describe('Second Batch', async () => {
await Promise.all([
it('Test 2.1', async () => {
await simulateDelay(125);
assertEqual(true, true, 'Test 2.1 passed');
}),
it('Test 2.2', async () => {
await simulateDelay(150);
assertEqual(1, 2, 'This test should fail');
}),
it('Test 2.3', async () => {
await simulateDelay(175);
assertEqual(true, true, 'Test 2.3 passed');
})
]);
});
}

function thirdFunction() {
describe('Third Layer', () => {
it('First', () => {
assertEqual(1, 1, 'Expected 1 to equal 1');
});
it('Second', () => {
assertEqual(1, 2, 'Expected 1 to equal 1');
});
it('Third', () => {
assertEqual(1, 1, 'Expected 1 to equal 1');
});
// Test batch 3
async function batchThree() {
await describe('Third Batch', async () => {
await Promise.all([
it('Test 3.1', async () => {
await simulateDelay(200);
assertEqual(true, true, 'Test 3.1 passed');
}),
it('Test 3.2', async () => {
await simulateDelay(225);
assertEqual(true, true, 'Test 3.2 passed');
}),
it('Test 3.3', async () => {
await simulateDelay(250);
assertEqual({ a: 1 }, { a: 1 }, 'Test 3.3 passed');
})
]);
});
}

function simulateDelay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

0 comments on commit 70abc51

Please sign in to comment.