feat(assertion): Add toBeDefined assertion method

This commit is contained in:
2024-08-17 07:27:32 +02:00
parent 537545766c
commit 9ef1e5120e
5 changed files with 3920 additions and 2742 deletions

View File

@ -1,8 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
* autocreated commitinfo by @push.rocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartexpect',
version: '1.0.21',
description: 'manage expectations in code'
version: '1.1.0',
description: 'A testing library to manage expectations in code, offering both synchronous and asynchronous assertion methods.'
}

View File

@ -71,6 +71,22 @@ export class Assertion {
}
}
/**
* checks if the given object is defined
*/
public toBeDefined() {
return this.runCheck(() => {
if (this.getObjectToTestReference() === undefined) {
throw new Error(
`${this.baseReference} with drill down ${this.propertyDrillDown} is not defined`
);
}
});
}
/**
* checks if the given object is not defined
*/
public toBeTypeofString() {
return this.runCheck(() => {
if (typeof this.getObjectToTestReference() !== 'string') {