fix(build): Corrected package.json and workflow dependencies and resolved formatting issues in tests.
This commit is contained in:
parent
5801d34f18
commit
ed9a9b7f2c
@ -119,6 +119,6 @@ jobs:
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
pnpm install -g @gitzone/tsdoc
|
||||
pnpm install -g @git.zone/tsdoc
|
||||
npmci command tsdoc
|
||||
continue-on-error: true
|
||||
|
@ -1,5 +1,12 @@
|
||||
# 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)
|
||||
Enhanced the assertion error messaging and added new test cases.
|
||||
|
||||
|
10
package.json
10
package.json
@ -10,14 +10,14 @@
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(tstest test/ --web)",
|
||||
"build": "(tsbuild --web)",
|
||||
"build": "(tsbuild tsfolders)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.66",
|
||||
"@gitzone/tsbundle": "^2.0.8",
|
||||
"@gitzone/tsrun": "^1.2.44",
|
||||
"@gitzone/tstest": "^1.0.77",
|
||||
"@git.zone/tsbuild": "^2.2.1",
|
||||
"@git.zone/tsbundle": "^2.2.5",
|
||||
"@git.zone/tsrun": "^1.3.3",
|
||||
"@git.zone/tstest": "^1.0.96",
|
||||
"@push.rocks/tapbundle": "^5.5.6",
|
||||
"@types/node": "^22.13.9"
|
||||
},
|
||||
|
3182
pnpm-lock.yaml
generated
3182
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -5,16 +5,16 @@ tap.test('basic type assertions', async () => {
|
||||
// String type checks
|
||||
smartexpect.expect('hello').toBeTypeofString();
|
||||
smartexpect.expect(1).not.toBeTypeofString();
|
||||
|
||||
|
||||
// Boolean type checks
|
||||
smartexpect.expect(true).toBeTypeofBoolean();
|
||||
smartexpect.expect(false).toBeTypeofBoolean();
|
||||
smartexpect.expect(1).not.toBeTypeofBoolean();
|
||||
|
||||
|
||||
// Number type checks
|
||||
smartexpect.expect(42).toBeTypeofNumber();
|
||||
smartexpect.expect(true).not.toBeTypeofNumber();
|
||||
|
||||
|
||||
// Generic type checks with new method
|
||||
smartexpect.expect(() => {}).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).not.toBeTypeofBoolean();
|
||||
|
||||
|
||||
// Test async timeout handling
|
||||
const longOperation = toolsArg.defer();
|
||||
toolsArg.delayFor(3000).then(() => {
|
||||
@ -48,23 +48,23 @@ tap.test('equality and matching assertions', async () => {
|
||||
// Basic equality
|
||||
smartexpect.expect('hithere').toEqual('hithere');
|
||||
smartexpect.expect('hithere').not.toEqual('hithere2');
|
||||
|
||||
|
||||
// Object equality
|
||||
const obj1 = { a: 1, b: { c: true } };
|
||||
const obj2 = { a: 1, b: { c: true } };
|
||||
const obj3 = { a: 1, b: { c: false } };
|
||||
smartexpect.expect(obj1).toEqual(obj2);
|
||||
smartexpect.expect(obj1).not.toEqual(obj3);
|
||||
|
||||
|
||||
// RegExp matching
|
||||
smartexpect.expect('hithere').toMatch(/hi/);
|
||||
smartexpect.expect('hithere').toMatch(/^hithere$/);
|
||||
smartexpect.expect('hithere').not.toMatch(/ho/);
|
||||
|
||||
|
||||
// String inclusion
|
||||
smartexpect.expect('hithere').toInclude('hit');
|
||||
smartexpect.expect('hithere').not.toInclude('missing');
|
||||
|
||||
|
||||
// String start/end
|
||||
smartexpect.expect('hithere').toStartWith('hi');
|
||||
smartexpect.expect('hithere').toEndWith('ere');
|
||||
@ -76,25 +76,36 @@ tap.test('object property assertions', async () => {
|
||||
nested: {
|
||||
prop: 42,
|
||||
deeplyNested: {
|
||||
array: [1, 2, 3]
|
||||
}
|
||||
}
|
||||
array: [1, 2, 3],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// Basic property checks
|
||||
smartexpect.expect(testObject).toHaveProperty('topLevel');
|
||||
smartexpect.expect(testObject).toHaveProperty('topLevel', 'hello');
|
||||
smartexpect.expect(testObject).not.toHaveProperty('missing');
|
||||
|
||||
|
||||
// Drill-down property navigation
|
||||
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
|
||||
smartexpect.expect(testObject).toHaveDeepProperty(['nested', 'deeplyNested', 'array']);
|
||||
|
||||
|
||||
// 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 () => {
|
||||
@ -103,7 +114,7 @@ tap.test('numeric comparison assertions', async () => {
|
||||
smartexpect.expect(4).toBeLessThan(5);
|
||||
smartexpect.expect(4).toBeGreaterThanOrEqual(4);
|
||||
smartexpect.expect(4).toBeLessThanOrEqual(4);
|
||||
|
||||
|
||||
// Approximate equality
|
||||
smartexpect.expect(0.1 + 0.2).toBeCloseTo(0.3, 10);
|
||||
});
|
||||
@ -112,26 +123,26 @@ tap.test('array assertions', async () => {
|
||||
const obj1 = { id: 1 };
|
||||
const obj2 = { id: 2 };
|
||||
const testArray = [1, 'two', obj1, true];
|
||||
|
||||
|
||||
// Basic array checks
|
||||
smartexpect.expect(testArray).toBeArray();
|
||||
smartexpect.expect(testArray).toHaveLength(4);
|
||||
|
||||
|
||||
// Content checks
|
||||
smartexpect.expect(testArray).toContain('two');
|
||||
smartexpect.expect(testArray).toContain(obj1);
|
||||
smartexpect.expect(testArray).not.toContain(obj2);
|
||||
|
||||
|
||||
// Array with equal items (not same reference)
|
||||
smartexpect.expect([{ a: 1 }, { b: 2 }]).toContainEqual({ a: 1 });
|
||||
|
||||
|
||||
// Multiple values
|
||||
smartexpect.expect(testArray).toContainAll([1, 'two']);
|
||||
smartexpect.expect(testArray).toExclude('missing');
|
||||
|
||||
|
||||
// Empty array
|
||||
smartexpect.expect([]).toBeEmptyArray();
|
||||
|
||||
|
||||
// Length comparisons
|
||||
smartexpect.expect(testArray).toHaveLengthGreaterThan(3);
|
||||
smartexpect.expect(testArray).toHaveLengthLessThan(5);
|
||||
@ -141,11 +152,11 @@ tap.test('boolean assertions', async () => {
|
||||
// True/False
|
||||
smartexpect.expect(true).toBeTrue();
|
||||
smartexpect.expect(false).toBeFalse();
|
||||
|
||||
|
||||
// Truthy/Falsy
|
||||
smartexpect.expect('something').toBeTruthy();
|
||||
smartexpect.expect(0).toBeFalsy();
|
||||
|
||||
|
||||
// Null/Undefined
|
||||
smartexpect.expect(null).toBeNull();
|
||||
smartexpect.expect(undefined).toBeUndefined();
|
||||
@ -155,10 +166,12 @@ tap.test('boolean assertions', async () => {
|
||||
|
||||
tap.test('function assertions', async () => {
|
||||
// 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(Error);
|
||||
|
||||
|
||||
// Function that doesn't throw
|
||||
const nonThrowingFn = () => 'safe';
|
||||
smartexpect.expect(nonThrowingFn).not.toThrow();
|
||||
@ -168,7 +181,7 @@ tap.test('date assertions', async () => {
|
||||
const now = new Date();
|
||||
const past = new Date(Date.now() - 10000);
|
||||
const future = new Date(Date.now() + 10000);
|
||||
|
||||
|
||||
smartexpect.expect(now).toBeDate();
|
||||
smartexpect.expect(now).toBeAfterDate(past);
|
||||
smartexpect.expect(now).toBeBeforeDate(future);
|
||||
@ -176,15 +189,10 @@ tap.test('date assertions', async () => {
|
||||
|
||||
tap.test('custom assertions', async () => {
|
||||
// Custom validation logic
|
||||
smartexpect.expect(42).customAssertion(
|
||||
value => value % 2 === 0,
|
||||
'Expected number to be even'
|
||||
);
|
||||
|
||||
smartexpect.expect(42).customAssertion((value) => value % 2 === 0, 'Expected number to be even');
|
||||
|
||||
// With fail message
|
||||
smartexpect.expect('test')
|
||||
.setFailMessage('Custom fail message for assertion')
|
||||
.toHaveLength(4);
|
||||
smartexpect.expect('test').setFailMessage('Custom fail message for assertion').toHaveLength(4);
|
||||
});
|
||||
|
||||
tap.test('logging and debugging', async () => {
|
||||
@ -192,13 +200,19 @@ tap.test('logging and debugging', async () => {
|
||||
const complexObject = {
|
||||
level1: {
|
||||
level2: {
|
||||
value: 'nested value'
|
||||
}
|
||||
}
|
||||
value: 'nested value',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
// 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();
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
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.'
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user