feat(Assertion): Add toBeTypeOf assertion method
This commit is contained in:
parent
7ae5b4378a
commit
e688207d23
@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2025-03-04 - 1.5.0 - feat(Assertion)
|
||||||
|
Add toBeTypeOf assertion method
|
||||||
|
|
||||||
|
- Introduced a new assertion method `toBeTypeOf` allowing checks for expected data types.
|
||||||
|
- Updated devDependencies and dependencies to their latest versions.
|
||||||
|
|
||||||
## 2024-12-30 - 1.4.0 - feat(Assertion)
|
## 2024-12-30 - 1.4.0 - feat(Assertion)
|
||||||
Add log method to Assertion class
|
Add log method to Assertion class
|
||||||
|
|
||||||
|
11
package.json
11
package.json
@ -18,12 +18,12 @@
|
|||||||
"@gitzone/tsbundle": "^2.0.8",
|
"@gitzone/tsbundle": "^2.0.8",
|
||||||
"@gitzone/tsrun": "^1.2.44",
|
"@gitzone/tsrun": "^1.2.44",
|
||||||
"@gitzone/tstest": "^1.0.77",
|
"@gitzone/tstest": "^1.0.77",
|
||||||
"@push.rocks/tapbundle": "^5.5.0",
|
"@push.rocks/tapbundle": "^5.5.6",
|
||||||
"@types/node": "^22.9.0"
|
"@types/node": "^22.13.9"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@push.rocks/smartdelay": "^3.0.5",
|
"@push.rocks/smartdelay": "^3.0.5",
|
||||||
"@push.rocks/smartpromise": "^4.0.4",
|
"@push.rocks/smartpromise": "^4.2.3",
|
||||||
"fast-deep-equal": "^3.1.3"
|
"fast-deep-equal": "^3.1.3"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
@ -57,5 +57,10 @@
|
|||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://code.foss.global/push.rocks/smartexpect.git"
|
"url": "https://code.foss.global/push.rocks/smartexpect.git"
|
||||||
|
},
|
||||||
|
"pnpm": {
|
||||||
|
"onlyBuiltDependencies": [
|
||||||
|
"mongodb-memory-server"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2767
pnpm-lock.yaml
generated
2767
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartexpect',
|
name: '@push.rocks/smartexpect',
|
||||||
version: '1.4.0',
|
version: '1.5.0',
|
||||||
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.'
|
||||||
}
|
}
|
||||||
|
@ -209,6 +209,20 @@ export class Assertion {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public toBeTypeOf(expectedType: string) {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
const actualType = typeof this.getObjectToTestReference();
|
||||||
|
if (actualType !== expectedType) {
|
||||||
|
throw new Error(
|
||||||
|
this.failMessage ||
|
||||||
|
`Assertion failed: ${this.baseReference} with drill down ${
|
||||||
|
this.propertyDrillDown
|
||||||
|
} is not of type ${expectedType}, but typeof ${actualType}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public toHaveProperty(propertyArg: string, equalsArg?: any) {
|
public toHaveProperty(propertyArg: string, equalsArg?: any) {
|
||||||
return this.runCheck(() => {
|
return this.runCheck(() => {
|
||||||
const obj = this.getObjectToTestReference();
|
const obj = this.getObjectToTestReference();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user