fix(build): Corrected package.json and workflow dependencies and resolved formatting issues in tests.

This commit is contained in:
Philipp Kunz 2025-03-04 12:32:00 +00:00
parent 5801d34f18
commit ed9a9b7f2c
6 changed files with 2250 additions and 1051 deletions

View File

@ -119,6 +119,6 @@ jobs:
run: | run: |
npmci node install stable npmci node install stable
npmci npm install npmci npm install
pnpm install -g @gitzone/tsdoc pnpm install -g @git.zone/tsdoc
npmci command tsdoc npmci command tsdoc
continue-on-error: true continue-on-error: true

View File

@ -1,5 +1,12 @@
# Changelog # Changelog
## 2025-03-04 - 1.6.1 - fix(build)
Corrected package.json and workflow dependencies and resolved formatting issues in tests.
- Fixed incorrect global npm package reference for tsdoc installation in workflow file.
- Updated dependencies in package.json for consistency in package naming.
- Resolved inconsistent formatting and spacing in test files.
## 2025-03-04 - 1.6.0 - feat(assertion) ## 2025-03-04 - 1.6.0 - feat(assertion)
Enhanced the assertion error messaging and added new test cases. Enhanced the assertion error messaging and added new test cases.

View File

@ -10,14 +10,14 @@
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "(tstest test/ --web)", "test": "(tstest test/ --web)",
"build": "(tsbuild --web)", "build": "(tsbuild tsfolders)",
"buildDocs": "tsdoc" "buildDocs": "tsdoc"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.66", "@git.zone/tsbuild": "^2.2.1",
"@gitzone/tsbundle": "^2.0.8", "@git.zone/tsbundle": "^2.2.5",
"@gitzone/tsrun": "^1.2.44", "@git.zone/tsrun": "^1.3.3",
"@gitzone/tstest": "^1.0.77", "@git.zone/tstest": "^1.0.96",
"@push.rocks/tapbundle": "^5.5.6", "@push.rocks/tapbundle": "^5.5.6",
"@types/node": "^22.13.9" "@types/node": "^22.13.9"
}, },

3182
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -5,16 +5,16 @@ tap.test('basic type assertions', async () => {
// String type checks // String type checks
smartexpect.expect('hello').toBeTypeofString(); smartexpect.expect('hello').toBeTypeofString();
smartexpect.expect(1).not.toBeTypeofString(); smartexpect.expect(1).not.toBeTypeofString();
// Boolean type checks // Boolean type checks
smartexpect.expect(true).toBeTypeofBoolean(); smartexpect.expect(true).toBeTypeofBoolean();
smartexpect.expect(false).toBeTypeofBoolean(); smartexpect.expect(false).toBeTypeofBoolean();
smartexpect.expect(1).not.toBeTypeofBoolean(); smartexpect.expect(1).not.toBeTypeofBoolean();
// Number type checks // Number type checks
smartexpect.expect(42).toBeTypeofNumber(); smartexpect.expect(42).toBeTypeofNumber();
smartexpect.expect(true).not.toBeTypeofNumber(); smartexpect.expect(true).not.toBeTypeofNumber();
// Generic type checks with new method // Generic type checks with new method
smartexpect.expect(() => {}).toBeTypeOf('function'); smartexpect.expect(() => {}).toBeTypeOf('function');
smartexpect.expect(class Test {}).toBeTypeOf('function'); smartexpect.expect(class Test {}).toBeTypeOf('function');
@ -29,7 +29,7 @@ tap.test('async tests', async (toolsArg) => {
}); });
await smartexpect.expectAsync(deferred.promise).timeout(2000).toBeTypeofString(); await smartexpect.expectAsync(deferred.promise).timeout(2000).toBeTypeofString();
await smartexpect.expectAsync(deferred.promise).not.toBeTypeofBoolean(); await smartexpect.expectAsync(deferred.promise).not.toBeTypeofBoolean();
// Test async timeout handling // Test async timeout handling
const longOperation = toolsArg.defer(); const longOperation = toolsArg.defer();
toolsArg.delayFor(3000).then(() => { toolsArg.delayFor(3000).then(() => {
@ -48,23 +48,23 @@ tap.test('equality and matching assertions', async () => {
// Basic equality // Basic equality
smartexpect.expect('hithere').toEqual('hithere'); smartexpect.expect('hithere').toEqual('hithere');
smartexpect.expect('hithere').not.toEqual('hithere2'); smartexpect.expect('hithere').not.toEqual('hithere2');
// Object equality // Object equality
const obj1 = { a: 1, b: { c: true } }; const obj1 = { a: 1, b: { c: true } };
const obj2 = { a: 1, b: { c: true } }; const obj2 = { a: 1, b: { c: true } };
const obj3 = { a: 1, b: { c: false } }; const obj3 = { a: 1, b: { c: false } };
smartexpect.expect(obj1).toEqual(obj2); smartexpect.expect(obj1).toEqual(obj2);
smartexpect.expect(obj1).not.toEqual(obj3); smartexpect.expect(obj1).not.toEqual(obj3);
// RegExp matching // RegExp matching
smartexpect.expect('hithere').toMatch(/hi/); smartexpect.expect('hithere').toMatch(/hi/);
smartexpect.expect('hithere').toMatch(/^hithere$/); smartexpect.expect('hithere').toMatch(/^hithere$/);
smartexpect.expect('hithere').not.toMatch(/ho/); smartexpect.expect('hithere').not.toMatch(/ho/);
// String inclusion // String inclusion
smartexpect.expect('hithere').toInclude('hit'); smartexpect.expect('hithere').toInclude('hit');
smartexpect.expect('hithere').not.toInclude('missing'); smartexpect.expect('hithere').not.toInclude('missing');
// String start/end // String start/end
smartexpect.expect('hithere').toStartWith('hi'); smartexpect.expect('hithere').toStartWith('hi');
smartexpect.expect('hithere').toEndWith('ere'); smartexpect.expect('hithere').toEndWith('ere');
@ -76,25 +76,36 @@ tap.test('object property assertions', async () => {
nested: { nested: {
prop: 42, prop: 42,
deeplyNested: { deeplyNested: {
array: [1, 2, 3] array: [1, 2, 3],
} },
} },
}; };
// Basic property checks // Basic property checks
smartexpect.expect(testObject).toHaveProperty('topLevel'); smartexpect.expect(testObject).toHaveProperty('topLevel');
smartexpect.expect(testObject).toHaveProperty('topLevel', 'hello'); smartexpect.expect(testObject).toHaveProperty('topLevel', 'hello');
smartexpect.expect(testObject).not.toHaveProperty('missing'); smartexpect.expect(testObject).not.toHaveProperty('missing');
// Drill-down property navigation // Drill-down property navigation
smartexpect.expect(testObject).property('nested').toHaveProperty('prop', 42); smartexpect.expect(testObject).property('nested').toHaveProperty('prop', 42);
smartexpect.expect(testObject).property('nested').property('deeplyNested').property('array').toBeArray(); smartexpect
.expect(testObject)
.property('nested')
.property('deeplyNested')
.property('array')
.toBeArray();
// Deep property checks // Deep property checks
smartexpect.expect(testObject).toHaveDeepProperty(['nested', 'deeplyNested', 'array']); smartexpect.expect(testObject).toHaveDeepProperty(['nested', 'deeplyNested', 'array']);
// Array item navigation // Array item navigation
smartexpect.expect(testObject).property('nested').property('deeplyNested').property('array').arrayItem(0).toEqual(1); smartexpect
.expect(testObject)
.property('nested')
.property('deeplyNested')
.property('array')
.arrayItem(0)
.toEqual(1);
}); });
tap.test('numeric comparison assertions', async () => { tap.test('numeric comparison assertions', async () => {
@ -103,7 +114,7 @@ tap.test('numeric comparison assertions', async () => {
smartexpect.expect(4).toBeLessThan(5); smartexpect.expect(4).toBeLessThan(5);
smartexpect.expect(4).toBeGreaterThanOrEqual(4); smartexpect.expect(4).toBeGreaterThanOrEqual(4);
smartexpect.expect(4).toBeLessThanOrEqual(4); smartexpect.expect(4).toBeLessThanOrEqual(4);
// Approximate equality // Approximate equality
smartexpect.expect(0.1 + 0.2).toBeCloseTo(0.3, 10); smartexpect.expect(0.1 + 0.2).toBeCloseTo(0.3, 10);
}); });
@ -112,26 +123,26 @@ tap.test('array assertions', async () => {
const obj1 = { id: 1 }; const obj1 = { id: 1 };
const obj2 = { id: 2 }; const obj2 = { id: 2 };
const testArray = [1, 'two', obj1, true]; const testArray = [1, 'two', obj1, true];
// Basic array checks // Basic array checks
smartexpect.expect(testArray).toBeArray(); smartexpect.expect(testArray).toBeArray();
smartexpect.expect(testArray).toHaveLength(4); smartexpect.expect(testArray).toHaveLength(4);
// Content checks // Content checks
smartexpect.expect(testArray).toContain('two'); smartexpect.expect(testArray).toContain('two');
smartexpect.expect(testArray).toContain(obj1); smartexpect.expect(testArray).toContain(obj1);
smartexpect.expect(testArray).not.toContain(obj2); smartexpect.expect(testArray).not.toContain(obj2);
// Array with equal items (not same reference) // Array with equal items (not same reference)
smartexpect.expect([{ a: 1 }, { b: 2 }]).toContainEqual({ a: 1 }); smartexpect.expect([{ a: 1 }, { b: 2 }]).toContainEqual({ a: 1 });
// Multiple values // Multiple values
smartexpect.expect(testArray).toContainAll([1, 'two']); smartexpect.expect(testArray).toContainAll([1, 'two']);
smartexpect.expect(testArray).toExclude('missing'); smartexpect.expect(testArray).toExclude('missing');
// Empty array // Empty array
smartexpect.expect([]).toBeEmptyArray(); smartexpect.expect([]).toBeEmptyArray();
// Length comparisons // Length comparisons
smartexpect.expect(testArray).toHaveLengthGreaterThan(3); smartexpect.expect(testArray).toHaveLengthGreaterThan(3);
smartexpect.expect(testArray).toHaveLengthLessThan(5); smartexpect.expect(testArray).toHaveLengthLessThan(5);
@ -141,11 +152,11 @@ tap.test('boolean assertions', async () => {
// True/False // True/False
smartexpect.expect(true).toBeTrue(); smartexpect.expect(true).toBeTrue();
smartexpect.expect(false).toBeFalse(); smartexpect.expect(false).toBeFalse();
// Truthy/Falsy // Truthy/Falsy
smartexpect.expect('something').toBeTruthy(); smartexpect.expect('something').toBeTruthy();
smartexpect.expect(0).toBeFalsy(); smartexpect.expect(0).toBeFalsy();
// Null/Undefined // Null/Undefined
smartexpect.expect(null).toBeNull(); smartexpect.expect(null).toBeNull();
smartexpect.expect(undefined).toBeUndefined(); smartexpect.expect(undefined).toBeUndefined();
@ -155,10 +166,12 @@ tap.test('boolean assertions', async () => {
tap.test('function assertions', async () => { tap.test('function assertions', async () => {
// Function that throws // Function that throws
const throwingFn = () => { throw new Error('test error'); }; const throwingFn = () => {
throw new Error('test error');
};
smartexpect.expect(throwingFn).toThrow(); smartexpect.expect(throwingFn).toThrow();
smartexpect.expect(throwingFn).toThrow(Error); smartexpect.expect(throwingFn).toThrow(Error);
// Function that doesn't throw // Function that doesn't throw
const nonThrowingFn = () => 'safe'; const nonThrowingFn = () => 'safe';
smartexpect.expect(nonThrowingFn).not.toThrow(); smartexpect.expect(nonThrowingFn).not.toThrow();
@ -168,7 +181,7 @@ tap.test('date assertions', async () => {
const now = new Date(); const now = new Date();
const past = new Date(Date.now() - 10000); const past = new Date(Date.now() - 10000);
const future = new Date(Date.now() + 10000); const future = new Date(Date.now() + 10000);
smartexpect.expect(now).toBeDate(); smartexpect.expect(now).toBeDate();
smartexpect.expect(now).toBeAfterDate(past); smartexpect.expect(now).toBeAfterDate(past);
smartexpect.expect(now).toBeBeforeDate(future); smartexpect.expect(now).toBeBeforeDate(future);
@ -176,15 +189,10 @@ tap.test('date assertions', async () => {
tap.test('custom assertions', async () => { tap.test('custom assertions', async () => {
// Custom validation logic // Custom validation logic
smartexpect.expect(42).customAssertion( smartexpect.expect(42).customAssertion((value) => value % 2 === 0, 'Expected number to be even');
value => value % 2 === 0,
'Expected number to be even'
);
// With fail message // With fail message
smartexpect.expect('test') smartexpect.expect('test').setFailMessage('Custom fail message for assertion').toHaveLength(4);
.setFailMessage('Custom fail message for assertion')
.toHaveLength(4);
}); });
tap.test('logging and debugging', async () => { tap.test('logging and debugging', async () => {
@ -192,13 +200,19 @@ tap.test('logging and debugging', async () => {
const complexObject = { const complexObject = {
level1: { level1: {
level2: { level2: {
value: 'nested value' value: 'nested value',
} },
} },
}; };
// This logs the current value in the chain for debugging // This logs the current value in the chain for debugging
smartexpect.expect(complexObject).property('level1').property('level2').log().property('value').toEqual('nested value'); smartexpect
.expect(complexObject)
.property('level1')
.property('level2')
.log()
.property('value')
.toEqual('nested value');
}); });
export default tap.start(); export default tap.start();

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@push.rocks/smartexpect', name: '@push.rocks/smartexpect',
version: '1.6.0', version: '1.6.1',
description: 'A testing library to manage expectations in code, offering both synchronous and asynchronous assertion methods.' description: 'A testing library to manage expectations in code, offering both synchronous and asynchronous assertion methods.'
} }