Skip to content

angular-package/testing

 
 

Repository files navigation

Packages

Useful and simple to use packages based on the angular.io.

Package Description Status
change-detection Improve application performance. npm version
core Core features. npm version
prism Prism highlighter module. npm version
property Features to handle object properties. npm version
reactive Automatize process of creating some rxjs features. npm version
ui User interface. In Progress
type Common types, type guards and type checkers. npm version
testing Support for testing other packages. npm version

Click on the package name to visit the package GitHub README.md

angular-package/testing

Support for testing other packages.

npm version

GitHub issues GitHub forks GitHub stars GitHub license

GitHub sponsors Support me on Patreon

Table of contents


How angular-package understands

Checks

Is to check the provided value to be the same as expected.

Type guard (constrain)

Constrains the parameter type to not let input unexpected value in the code editor.

Guards

Is a combination of both above, constrains the type of the parameter in the code editor, and checks its argument.

Sets

Sets the provided value in the object.

Defines

Returns defined value from the method, instead of storing it in the object.


Skeleton

This package was built by the library skeleton which was generated with Angular CLI version 12.1.1.

Copy this package to the packages/testing folder of the library skeleton then run the commands below.

Build

Run ng build testing to build the package. The build artifacts will be stored in the dist/ directory.

Running unit tests

Run ng test testing to execute the unit tests via Karma.


Installation

Install @angular-package/testing package with command:

npm i --save @angular-package/testing

Instance of

Possible names of javascript objects that can be checked by the instanceof operator.

const value: any = new Object({});
value instanceof Array
value instanceof ArrayBuffer;
value instanceof Boolean;
value instanceof DataView;
value instanceof Date;
value instanceof Error;
value instanceof EvalError;
value instanceof Int16Array;
value instanceof Int32Array;
value instanceof Int8Array;
value instanceof Map;
value instanceof Promise;
value instanceof RangeError
value instanceof RangeError;
value instanceof ReferenceError;
value instanceof RegExp;
value instanceof Set;
value instanceof SharedArrayBuffer;
value instanceof SyntaxError;
value instanceof Float32Array;
value instanceof Float64Array;
value instanceof Function;
value instanceof Number;
value instanceof Object;
value instanceof String;
value instanceof Storage;
value instanceof TypeError;
value instanceof Uint16Array;
value instanceof Uint32Array;
value instanceof Uint8Array;
value instanceof Uint8ClampedArray;
value instanceof URIError;
value instanceof WeakMap;
value instanceof WeakSet;

Testing

Testing

Simple class to support testing.

Methods prefixed with the toBe aren't working with the beforeEach() function of jasmine.

Static methods:

Testing. Description
defineDescribe() Defines the wrapper function of the describe() function of jasmine with the ability to decide its execution
defineIt() Defines the wrapper function of the it() function of jasmine with the ability to decide its execution

Constructor:

Testing Description
constructor Creates an instance with setting for global allow executing of the describe() and it() methods, and optionally sets the list of allowed executable tests (those that execute even on the disallowed state)

Instance methods:

Testing.prototype. Description
describe() Executes defined describe() function of jasmine on a state true from the execute
it() Executes defined it() function of jasmine on a state true from the execute
toBe() Executes the spec on a state true from the execute expecting the provided value to be the given expected value
toBeBigInt() Executes the spec on a state true from the execute expecting the provided value to be a bigint type on the given expected state of true
toBeBooleanType() Executes the spec on a state true from the execute expecting the provided value to be of a boolean type on the given expected state of true
toBeClass() Executes the spec on a state true from the execute expecting the provided value to be a class on the given expected state of true
toBeInstanceOfArray() Executes the spec on a state true from the execute expecting the provided value to be an instance of an Array on the given expected state of true
toBeInstanceOfBoolean() Executes the spec on a state true from the execute expecting the provided value to be an instance of Boolean on the given expected state of true
toBeInstanceOfDate() Executes the spec on a state true from the execute expecting the provided value to be an instance of Date on the given expected state of true
toBeInstanceOfError() Executes the spec on a state true from the execute expecting the provided value to be an instance of an Error on the given expected state of true
toBeInstanceOfFunction() Executes the spec on a state true from the execute expecting the provided value to be an instance of a Function on the given expected state of true
toBeInstanceOfMap() Executes the spec on a state true from the execute expecting the provided value to be an instance of a Map on the given expected state of true
toBeInstanceOfNumber() Executes the spec on a state true from the execute expecting the provided value to be an instance of a Number on the given expected state of true
toBeInstanceOfObject() Executes the spec on a state true from the execute expecting the provided value to be an instance of an Object on the given expected state of true
toBeInstanceOfPromise() Executes the spec on a state true from the execute expecting the provided value to be an instance of Promise on the given expected state of true
toBeInstanceOfRangeError() Executes the spec on a state true from the execute expecting the provided value to be an instance of RangeError on the given expected state of true
toBeInstanceOfReferenceError() Executes the spec on a state true from the execute expecting the provided value to be an instance of ReferenceError on the given expected state of true
toBeInstanceOfRegExp() Executes the spec on a state true from the execute expecting the provided value to be an instance of RegExp on the given expected state of true
toBeInstanceOfSet() Executes the spec on a state true from the execute expecting the provided value to be an instance of Set on the given expected state of true
toBeInstanceOfStorage() Executes the spec on a state true from the execute expecting the provided value to be an instance of Storage on the given expected state of true
toBeInstanceOfString() Executes the spec on a state true from the execute expecting the provided value to be an instance of a String on the given expected state of true
toBeInstanceOfSyntaxError() Executes the spec on a state true from the execute expecting the provided value to be an instance of SyntaxError on the given expected state of true
toBeInstanceOfTypeError() Executes the spec on a state true from the execute expecting the provided value to be an instance of TypeError on the given expected state of true
toBeInstanceOfURIError() Executes the spec on a state true from the execute expecting the provided value to be an instance of URIError on the given expected state of true
toBeInstanceOfWeakSet() Executes the spec on a state true from the execute expecting the provided value to be an instance of a WeakSet on the given expected state of true
toBeNull() Executes the spec on a state true from the execute expecting the provided value to be null on the given expected state of true
toBeNumberType() Executes the spec on a state true from the execute expecting the provided value to be of a number type on the given expected state of true
toBeStringType() Executes the spec on a state true from the execute expecting the provided value to be of a string type on the given expected state of true
toEqual() Executes the spec on a state true from the execute expecting the provided value to equal to the given expected

Testing constructor

Creates an instance with setting for global allow executing of the describe() and it() methods, and optionally sets the list of allowed executable tests (those that execute even on the disallowed state).

const testing = new Testing(
  true, // Allows executing the `describe()` method globally.
  true, // Allows executing the `it()` method globally.
  {
    describe: [], // Executable unique numbers from the `[counter]` of `describe()` methods to execute when global executing is disallowed.
    it: []        // Executable unique numbers from the `[counter]` of `it()` methods to execute when global executing is disallowed.
  }
);

Parameters:

Name: type Description
allowDescribe: boolean Allow executing describe() methods
allowIt: boolean Allow executing it() methods
executable: ExecutableTests An optional object with unique numbers of executable tests for describe() and it() method

Returns:

The return value is new instance of a Testing.

Usage:

// Example usage.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(
  true, // Allows executing the `describe()` method globally.
  true, // Allows executing the `it()` method globally.
  {
    describe: [], // Executable unique numbers of `describe()` methods to execute when global executing is disallowed.
    it: [], // Executable unique numbers of `it()` methods to execute when global executing is disallowed.
  }
);

Example of using allow.

/**
 * Initialize testing.
 */
const testing = new Testing(
  false, // Disallows executing the `describe()` method globally.
  false, // Disallows executing the `it()` method globally.
  {
    describe: [1, 2, 3, 5], // Executable unique numbers of `describe()` methods to execute when global executing is disallowed.
    it: [1], // Executable unique numbers of `it()` methods inside the `describe()` to execute when global executing is disallowed.
  }
);

testing.describe('[counter] First describe', () => {
  testing
    .it('[counter] First it() in first describe 1-1', () =>
      expect(false).toBeFalse()
    )
    .it('[counter] Second it() in first describe 1-2', () =>
      expect(true).toBeTrue()
    )
    .it('[counter] Second it() in first describe 1-3', () =>
      expect(true).toBeTrue()
    )
    .it('[counter] Fourth it() in first describe() 1-4', () =>
      expect(true).toBeTrue()
    )
    .describe('[counter] Second describe()', () => {
      testing.it('[counter] First it() in second describe() 2-1', () =>
        expect(true).toBeTrue()
      );
    })
    .describe('[counter] Third describe()', () => {
      testing.it('[counter] First it() in third describe() 3-1', () =>
        expect(true).toBeTrue()
      );
    })
    .describe('[counter] Fourth describe()', () => {
      testing.it('[counter] First it() in fourth describe() 3-1', () =>
        expect(true).toBeTrue()
      );
    });
});
testing.describe('[counter] Fifth describe', () =>
  testing.it('[counter] First it() in fifth describe 5-1', () =>
    expect(false).toBeFalse()
  )
);
/*
  Karma returns
  1 First describe
      1 First it() in first describe 1-1
    3 Third describe()
      1 First it() in third describe() 3-1
    2 Second describe()
      1 First it() in second describe() 2-1
  5 Fifth describe
    1 First it() in fifth describe 5-1 
*/

Testing static methods

Testing.defineDescribe()

Defines the wrapper function of the describe() function of jasmine with the ability to decide its execution.

static defineDescribe(
  description: string,
  specDefinitions: () => void
): (execute: boolean) => void {
  return TestingDescribe.define(description, specDefinitions);
}

Parameters:

Name: type Description
description: string "Textual description of the group" - jasmine
specDefinitions: () => void "Function for Jasmine to invoke that will define" - jasmine

Returns:

The return value is a function that contains the describe() function of jasmine with the ability to decide its execution.

Usage:

// Example usage.
// Object.
import { is } from '@angular-package/type';
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * Tests.
 */
const testingDescribe = Testing.defineDescribe('Primitives values', () => {
  const numberSpec = Testing.defineIt('The value must be a number type', () => {
    expect(is.number(5)).toBeTruthy();
  }, 3000);
  numberSpec(false); // Do not execute.
  numberSpec(true); // Execute.
});

testingDescribe(false); // Do not execute.
testingDescribe(true); // Execute.

Testing.defineIt()

Defines the wrapper function of the it() function of jasmine with the ability to decide its execution.

static defineIt(
  expectation: string,
  assertion: jasmine.ImplementationCallback,
  timeout?: number | undefined,
): (execute: boolean) => void {
  return TestingIt.define(expectation, assertion, timeout);
}

Parameters:

Name: type Description
description: string "Textual description of the group" - jasmine
specDefinitions: () => void "Function for Jasmine to invoke that will define" - jasmine

Returns:

The return value is a function that contains the describe() function of jasmine with the ability to decide its execution.

Usage:

// Example usage.
// Object.
import { is } from '@angular-package/type';
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * defineIt().
 */
testing.describe('defineIt()', () => {
  const numberSpec = Testing.defineIt('The value must be a number type', () => {
    expect(is.number(5)).toBeTruthy();
  }, 3000);
  numberSpec(false); // Do not execute.
  numberSpec(true); // Execute.
});

Testing instance methods

Testing.prototype.describe()

Executes defined describe() function of jasmine on provided state true from the execute, and resets the counter to 0.

public describe(
  description: string,
  specDefinitions: () => void,
  execute?: boolean
): this {
  this.#testingIt.resetCounter();
  this.#testingDescribe.describe(description, specDefinitions, execute);
  return this;
}

Parameters:

Name: type Description
description: string "Textual description of the group" with an optional its unique number inside the describe when adding [counter]
specDefinitions: () => void "Function for Jasmine to invoke that will define inner suites a specs"
execute: boolean A boolean type value to decide whether or not execute defined describe() of jasmine function

Returns:

The return value is an instance of a child class, which in this case is Testing.

Usage:

// Example usage.
// Object.
import { is } from '@angular-package/type';
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * describe().
 */
testing.describe(
  '[counter] describe()',
  () => {},
  true // Whether or not execute suite
);

Testing.prototype.it()

Executes defined it() function of jasmine on provided state true from the execute.

public it(
  expectation: string,
  assertion: jasmine.ImplementationCallback,
  execute?: boolean
): this {
  this.#testingIt.it(expectation, assertion, execute);
  return this;
}

Parameters:

Name: type Description
description: string "Textual description of what this spec is checking" with an optional its unique number when adding [counter]
specDefinitions: () => void "Function that contains the code of your test. If not provided the test will be pending."
execute: boolean A boolean type value to decide whether or not execute defined it() of jasmine function

Returns:

The return value is an instance of a child class, which in this case is Testing.

Usage:

// Example usage.
// Object.
import { is } from '@angular-package/type';
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * it().
 */
testing.describe(
  '[counter] describe()',
  () => testing.it('[counter] it()', () => {
      expect(true).toBeTruthy();
    },
    true // Whether or not execute spec
  ),
  true // Whether or not execute suite
);

Testing.prototype.toBe()

Executes the spec on a state true from the execute expecting the provided value to be the given expected value.

public toBe<Value>(
  expectation: string,
  value: Value,
  expected: any,
  execute?: boolean
): this {
  this.it(expectation, () => expect(value).toBe(expected), execute);
  return this;
}

Parameters:

Name: type Description
expectation: string "Textual description of what this spec is checking" with an optional its unique number when adding [counter]
value: Value The value of any type passed to the expect() function of jasmine
expected: any The value of any type passed to the toBe() method of jasmine.Matchers
execute?: boolean Whether or not to execute the spec

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Object.
import { is } from '@angular-package/type';
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBe().
 */
testing.describe('string', () => {
  testing.toBe(
    `Checks the value against the string`,
    is.stringType('my name'),
    true
  );
});

Testing.prototype.toBeBigInt()

Executes the spec on a state true from the execute expecting the provided value to be a bigint type on the expected of true.

public toBeBigInt<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be a \`bigint\` type`,
  expected: boolean = true
): this {
  this.toBe(expectation, is.bigint(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be a bigint type
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Object.
import { is } from '@angular-package/type';
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeBigInt().
 */
testing.describe('bigint', () => testing.toBeBigInt(1n));

Testing.prototype.toBeBooleanType()

Executes the spec on a state true from the execute expecting the provided value to be of a boolean type on the expected of true.

public toBeBooleanType<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be of a \`boolean\` type`,
  expected: boolean = true
): this {
  this.toBe(expectation, is.booleanType(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be of a boolean type
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeBooleanType().
 */
testing.describe('boolean', () => testing.toBeBooleanType(false));

Testing.prototype.toBeClass()

Executes the spec on a state true from the execute expecting the provided value to be a class on the expected of true.

public toBeClass<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be a \`class\``,
  expected: boolean = true
): this {
  this.toBe(expectation, is.class(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be a class
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeClass().
 */
testing.describe('class Person', () => {
  class Person {}
  testing.toBeClass(Person);
});

Testing.prototype.toBeInstanceOfArray()

Executes the spec on a state true from the execute expecting the provided value to be an instance of an Array on the expected of true.

public toBeInstanceOfArray<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be an instance of an \`${Array.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, is.array(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be an instance of an Array
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfArray().
 */
testing.describe('Array', () => testing.toBeInstanceOfArray(['1']));

Testing.prototype.toBeInstanceOfBoolean()

Executes the spec on a state true from the execute expecting the provided value to be an instance of Boolean on the expected of true.

public toBeInstanceOfBoolean<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be an instance of \`${Boolean.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, is.booleanObject(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be an instance of an Boolean
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfBoolean().
 */
testing.describe('Boolean', () => testing.toBeInstanceOfBoolean(new Boolean()));

Testing.prototype.toBeInstanceOfDate()

Executes the spec on a state true from the execute expecting the provided value to be an instance of Date on the expected of true.

public toBeInstanceOfDate<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be an instance of \`${Date.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, is.date(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be an instance of Date
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfDate().
 */
testing.describe('Date', () => testing.toBeInstanceOfDate(new Date()));

Testing.prototype.toBeInstanceOfError()

Executes the spec on a state true from the execute expecting the provided value to be an instance of an Error the expected of true.

public toBeInstanceOfError<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be an instance of an \`${Error.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, value instanceof Error, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be an instance of an Error
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfError().
 */
testing.describe('Error', () => {
  try {
    throw new Error();
  } catch (e) {
    testing.toBeInstanceOfError(e);
  }
});

Testing.prototype.toBeInstanceOfFunction()

Executes the spec on a state true from the execute expecting the provided value to be an instance of a Function on the expected of true.

public toBeInstanceOfFunction<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be an instance of a \`${Function.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, is.function(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be an instance of a Function
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfFunction().
 */
testing.describe(`Function`, () => testing.toBeInstanceOfFunction(() => {}));

Testing.prototype.toBeInstanceOfMap()

Executes the spec on a state true from the execute expecting the provided value to be an instance of a Map on the expected of true.

public toBeInstanceOfMap<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be an instance of a \`${Map.name}\``,
  expected: boolean = true,
): this {
  this.toBe(expectation, value instanceof Map, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be an instance of a Map
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfMap().
 */
testing.describe(`Map`, () => testing.toBeInstanceOfMap(new Map()));

Testing.prototype.toBeInstanceOfNumber()

Executes the spec on a state true from the execute expecting the provided value to be an instance of a Number on the expected of true.

public toBeInstanceOfNumber<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be an instance of a \`${Number.name}\``,
  expected: boolean = true,
): this {
  this.toBe(expectation, is.numberObject(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be an instance of a Number
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * Tests.
 */
testing.describe(`Number`, () =>
  testing.toBeInstanceOfNumber(new Number(27))
);

Testing.prototype.toBeInstanceOfObject()

Executes the spec on a state true from the execute expecting the provided value to be an instance of an Object on the expected of true.

public toBeInstanceOfObject<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be an instance of an \`${Object.name}\``,
  expected: boolean = true,
): this {
  this.toBe(expectation, is.object(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be an instance of an Object
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfObject()
 */
testing.describe(`Object`, () =>
  testing
    .toBeInstanceOfObject(new Object({}))
    .toBeInstanceOfObject({})
);

Testing.prototype.toBeInstanceOfPromise()

Executes the spec on a state true from the execute expecting the provided value to be an instance of Promise on the expected of true.

public toBeInstanceOfPromise<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be an instance of \`${Promise.name}\``,
  expected: boolean = true,
): this {
  this.toBe(expectation, value instanceof Promise, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be an instance of Promise
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfPromise()
 */
const myPromise = new Promise((resolve, reject) => {
  setTimeout(() => {
    resolve('foo');
    // reject('foo');
  }, 300);
});
testing.describe(`Promise`, () => testing.toBeInstanceOfPromise(myPromise));

Testing.prototype.toBeInstanceOfRangeError()

Executes the spec on a state true from the execute expecting the provided value to be an instance of RangeError on the expected state.

public toBeInstanceOfRangeError<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be an instance of \`${RangeError.name}\``,
  expected: boolean = true,
): this {
  this.toBe(expectation, value instanceof RangeError, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be an instance of RangeError
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfRangeError()
 */
testing.describe('RangeError', () => {
  try {
    throw new RangeError();
  } catch (e) {
    testing.toBeInstanceOfRangeError(e);
  }
});

Testing.prototype.toBeInstanceOfReferenceError()

Executes the spec on a state true from the execute expecting the provided value to be an instance of ReferenceError on the expected of true.

public toBeInstanceOfReferenceError<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be an instance of \`${ReferenceError.name}\``,
  expected: boolean = true,
): this {
  this.toBe(expectation, value instanceof ReferenceError, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be an instance of ReferenceError
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfRangeError()
 */
testing.describe('RangeError', () => {
  try {
    throw new RangeError();
  } catch (e) {
    testing.toBeInstanceOfRangeError(e);
  }
});

Testing.prototype.toBeInstanceOfRegExp()

Executes the spec on a state true from the execute expecting the provided value to be an instance of RegExp on the expected of true.

public toBeInstanceOfRegExp<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be an instance of \`${RegExp.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, is.regexp(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be an instance of RegExp
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfRegExp()
 */
testing.describe(`RegExp`, () =>
  testing.toBeInstanceOfRegExp(new RegExp(/[]/g))
);

Testing.prototype.toBeInstanceOfSet()

Executes the spec on a state true from the execute expecting the provided value to be an instance of Set on the expected of true.

public toBeInstanceOfSet<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be an instance of \`${Set.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, value instanceof Set, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be an instance of Set
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfSet()
 */
testing.describe(`Promise`, () => testing.toBeInstanceOfSet(new Set()));

Testing.prototype.toBeInstanceOfStorage()

Executes the spec on a state true from the execute expecting the provided value to be an instance of Storage on the expected of true.

public toBeInstanceOfStorage<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be an instance of \`${Storage.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, value instanceof SyntaxError, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be an instance of Storage
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfStorage()
 */
testing.describe(`Storage`, () => testing.toBeInstanceOfStorage(window.sessionStorage));

Testing.prototype.toBeInstanceOfString()

Executes the spec on a state true from the execute expecting the provided value to be an instance of a String on the expected of true.

public toBeInstanceOfString<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be an instance of a \`${String.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, is.stringObject(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be an instance of a String
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfString()
 */
testing.describe(`String`, () => testing.toBeInstanceOfString(new String()));

Testing.prototype.toBeInstanceOfSyntaxError()

Executes the spec on a state true from the execute expecting the provided value to be an instance of SyntaxError on the expected of true.

public toBeInstanceOfSyntaxError<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be an instance of \`${SyntaxError.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, value instanceof SyntaxError, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be an instance of SyntaxError
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfSyntaxError()
 */
testing.describe('SyntaxError', () => {
  try {
    throw new SyntaxError();
  } catch (e) {
    testing.toBeInstanceOfSyntaxError(e);
  }
});

Testing.prototype.toBeInstanceOfTypeError()

Executes the spec on a state true from the execute expecting the provided value to be an instance of SyntaxError on the expected of true.

public toBeInstanceOfSyntaxError<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be an instance of \`${SyntaxError.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, value instanceof SyntaxError, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be an instance of SyntaxError
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfTypeError()
 */
testing.describe('TypeError', () => {
  try {
    throw new TypeError();
  } catch (e) {
    testing.toBeInstanceOfTypeError(e);
  }
});

Testing.prototype.toBeInstanceOfURIError()

Executes the spec on a state true from the execute expecting the provided value to be an instance of URIError on the expected of true.

public toBeInstanceOfURIError<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be an instance of \`${URIError.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, value instanceof URIError, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be an instance of URIError
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfURIError()
 */
testing.describe('URIError', () => {
  try {
    throw new URIError();
  } catch (e) {
    testing.toBeInstanceOfURIError(e);
  }
});

Testing.prototype.toBeInstanceOfWeakSet()

Executes the spec on a state true from the execute expecting the provided value to be an instance of a WeakSet on the expected of true.

public toBeInstanceOfWeakSet<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be an instance of a \`${WeakSet.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, value instanceof WeakSet, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be an instance of WeakSet
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfWeakSet()
 */
testing.describe(`WeakSet`, () => testing.toBeInstanceOfWeakSet(new WeakSet()));

Testing.prototype.toBeNull()

Executes the spec on a state true from the execute expecting the provided value to be null on the expected of true.

public toBeNull<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be \`null\``,
  expected: boolean = true
): this {
  this.toBe(expectation, is.null(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be null
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeNull()
 */
testing.describe(`null`, () => testing.toBeNull(null));

Testing.prototype.toBeNumberType()

Executes the spec on a state true from the execute expecting the provided value to be of a number type on the expected of true.

public toBeNumberType<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be of a \`number\` type`,
  expected: boolean = true
): this {
  this.toBe(expectation, is.numberType(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be of a number type
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeNumberType()
 */
testing.describe(`number`, () => testing.toBeNumberType(5));

Testing.prototype.toBeStringType()

Executes the spec on a state true from the execute expecting the provided value to be of a string type on the expected of true.

public toBeStringType<Value>(
  value: Value,
  execute: boolean = true,
  expectation: string = `The value must be of a \`string\` type`,
  expected: boolean = true
): this {
  this.toBe(expectation, is.stringType(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check
execute: boolean Whether or not to execute the spec, by default it's set to true
expectation: string The message for the karma, which by default is set to The value must be of a string type
expected: boolean Expects the result of the expectation must be true or false, by default it's true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeStringType()
 */
testing.describe(`string`, () => testing.toBeStringType('my name'));

Testing.prototype.toEqual()

Executes the spec on a state true from the execute expecting the provided value to equal to the given expected.

"Expect the actual value to be equal to the expected, using deep equality comparison."

public toEqual<Value>(
  expectation: string,
  value: Value,
  expected: any,
  execute?: boolean
): this {
  this.it(expectation, () => expect(value).toEqual(expected), execute);
  return this;
}

Parameters:

Name: type Description
expectation: string "Textual description of what this spec is checking" with an optional its unique number when adding [counter]
value: Value The value of any type passed to the expect() function of jasmine
expected: boolean The value of any type passed to the toEqual() method of jasmine.Matchers. "The expected value to compare against."
execute: boolean Whether or not to execute the spec, by default it's set to true

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toEqual()
 */
const firstName = 'My name';
testing.describe(`toEqual`, () => testing.toEqual('Expects `firstName` to equal to `My name`', firstName, 'My name'));

TestingToBeMatchers

Matchers that use the toBe() method of jasmine.Matchers.

Instance methods:

TestingToBeMatchers.prototype. Description
array() Expects provided value to be an array
bigint() Expects provided value to be a bigint
boolean() Expects provided value to be a boolean type
class() Expects provided value to be a class
date() Expects provided value to be a Date
defined() Expects provided value to be defined
false() Expects provided value to be false
function() Expects provided value to be function
instance() Expects provided value to be an instance of the given class from the constructor
key() Expects provided value to be a property key
null() Expects provided value to be null
number() Expects provided value to be a number
numberBetween() Expects provided value to be a number between minimum and maximum
object() Expects provided value to be an object
objectKey() Expects provided value to be an object with the given keys by using the hasOwnProperty method of the Object
objectKeyIn() Expects provided value to be an object with the given keys by using the in operator
objectKeys() Expects provided value to be an object with some given keys by using the hasOwnProperty method of the Object
regexp() Expects provided value to be RegExp
string() Expects provided value to be a string
stringOfLength() Expects provided value to be a string of the specified minimum and maximum length
symbol() Expects provided value to be a symbol
true() Expects provided value to be true
undefined() Expects provided value to be undefined

TestingToBeMatchers.prototype.array()

new

Expects provided value to be an array. The method uses isArray() function from the @angular-package/type.

public array(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be an \`array\``
): this {
  this.toBe(is.array(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against the array and the result of its check is passed to the expect() function of jasmine
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) an array

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let testArray: any;
  beforeEach(() => (testArray = [1, 'two', 3]));

  testing.describe('to be or not', () => {
    testing.it('an array', () => toBe.array(testArray).not.array(2));
  });
});

TestingToBeMatchers.prototype.bigint()

new

Expects provided value to be bigint type. The method uses isBigInt() function from the @angular-package/type.

public bigint(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be \`bigint\``
): this {
  this.toBe(is.bigint(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against the bigint and the result of its check is passed to the expect() function of jasmine
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) bigint

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isBigint: any;
  beforeEach(() => (isBigint = 12n));

  testing.describe('to be or not', () => {
    testing.it('bigint', () => toBe.bigint(isBigint).not.bigint(2));
  });
});

TestingToBeMatchers.prototype.boolean()

new

Expects provided value to be boolean. The method uses isBoolean() function from the @angular-package/type.

public boolean(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be \`boolean\``
): this {
  this.toBe(is.boolean(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against the boolean and the result of its check is passed to the expect() function of jasmine
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) boolean

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isBoolean: any;
  beforeEach(() => (isBoolean = false));

  testing.describe('to be or not to be the type of', () => {
    testing.it('boolean', () => toBe.boolean(isBoolean).not.boolean(3));
  });
});

TestingToBeMatchers.prototype.class()

new

Expects provided value to be class. The method uses isClass() function from the @angular-package/type.

public class(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be \`class\``
): this {
  this.toBe(is.class(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against the class and the result of its check is passed to the expect() function of jasmine
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) class

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isClass: any;
  beforeEach(() => (isClass = class TestingClass {}));
  testing.describe('to be or not to be', () => {
    testing.it('class', () => toBe.class(isClass).not.class('TestingClass'));
  });
});

TestingToBeMatchers.prototype.date()

new

Expects provided value to be a date. The method uses isDate() function from the @angular-package/type.

public date(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be a \`date\``
): this {
  this.toBe(is.date(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against date and the result of its check is passed to the expect() function of jasmine
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) a date

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isDate: any;
  beforeEach(() => (isDate = new Date()));
  testing.describe('to be or not to be the type of', () => {
    testing.it('date', () => toBe.date(isDate).not.date(false));
  });
});

TestingToBeMatchers.prototype.defined()

new

Expects provided value to be defined. The method uses isDefined() function from the @angular-package/type.

public defined(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be defined`
): this {
  this.toBe(is.defined(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against defined and the result of its check is passed to the expect() function of jasmine
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) defined

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isDefined: any;
  testing.describe('to be or not to be', () => {
    testing.it('defined', () => toBe.defined('Defined').not.defined(isDefined));
  });
});

TestingToBeMatchers.prototype.false()

new

Expects provided value to be false. The method uses isFalse() function from the @angular-package/type.

public false(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be \`false\``
): this {
  this.toBe(is.false(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against false and the result of its check is passed to the expect() function of jasmine
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) false

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isFalse: any;
  beforeEach(() => (isFalse = false));
  testing.describe('to be or not to be', () => {
    testing.it('`false`', () => toBe.false(isFalse).not.false(true));
  });
});

TestingToBeMatchers.prototype.function()

new

Expects provided value to be function. The method uses isFunction() function from the @angular-package/type.

public function(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be a function`
): this {
  this.toBe(is.function(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against function and the result of its check is passed to the expect() function of jasmine
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) function

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isFunction: any;
  beforeEach(() => (isFunction = () => {}));
  testing.describe('to be or not to be', () => {
    testing.it('`function`', () => toBe.function(isFunction).not.function(true));
  });
});

TestingToBeMatchers.prototype.instance()

new

Expects provided value to be function. The method uses isFunction() function from the @angular-package/type.

public instance<Type>(
  value: any,
  constructor: Constructor<Type>,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be an instance of ${constructor.name}`
): this {
  this.toBe(is.instance(value, constructor), expected, expectationFailOutput);
  return this;
}

Generic type variables:

Name Description
Type A generic variable by default of value captured from a given constructor

Parameters:

Name: type Description
value: any The value of any type that is checked against function and the result of its check is passed to the expect() function of jasmine
constructor: Constructor<Type> A class or function that specifies the type of the constructor
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) an instance of the given class

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers, TestingClass } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isInstance: any;
  beforeEach(() => isInstance = new TestingClass());
  testing.describe('to be or not to be', () => {
    testing.it(`an instance of \`TestingClass\``, () => toBe.instance(isInstance, TestingClass).not.instance(isInstance, class Person {}));
  });
});

TestingToBeMatchers.prototype.key()

new

Expects provided value to be property key. The method uses isKey() function from the @angular-package/type.

public key(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be the property key`
): this {
  this.toBe(is.key(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against the property key and the result of its check is passed to the expect() function of jasmine
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) the property key

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isKey: any;
  beforeEach(() => (isKey = 'firstName'));
  testing.describe('to be or not to be', () => {
    testing.it('`key`', () => toBe.key(isKey).not.key(true));
  });
});

TestingToBeMatchers.prototype.null()

new

Expects provided value to be property key. The method uses isNull() function from the @angular-package/type.

public null(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be \`null\``
): this {
  this.toBe(is.null(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against null and the result of its check is passed to the expect() function of jasmine
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) null

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isNull: any;
  beforeEach(() => (isNull = null));
  testing.describe('to be or not to be', () => {
    testing.it('`null`', () => toBe.null(isNull).not.null(undefined));
  });
});

TestingToBeMatchers.prototype.number()

new

Expects provided value to be number. The method uses isNumber() function from the @angular-package/type.

public number(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be \`number\``
): this {
  this.toBe(is.number(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against number and the result of its check is passed to the expect() function of jasmine
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) a number

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isNumber: any;
  beforeEach(() => (isNumber = 27));
  testing.describe('to be or not to be', () => {
    testing.it('`number`', () => toBe.number(isNumber).not.number(undefined));
  });
});

TestingToBeMatchers.prototype.numberBetween()

new

Expects provided value to be number between a range. The method uses isNumberBetween() function from the @angular-package/type.

public numberBetween<Min extends number, Max extends number>(
  value: any,
  min: Min,
  max: Max,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be a number between ${min} to ${max}`
): this {
  this.toBe(
    is.numberBetween(value, min, max),
    expected,
    expectationFailOutput
  );
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against number of the specified range and the result of its check is passed to the expect() function of jasmine
min: Min A number of the minimum range of the given value
max: Max A number of the maximum range of the given value
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) a number between minimum to maximum

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isNumberBetween: any;
  let min: any;
  let max: any;
  beforeEach(() => {
    isNumberBetween = 27;
    min = 26;
    max = 28;
  });

  testing.describe('to be or not to be', () => {
    testing.it(`\`number\` between 26 to 28`, () => toBe.numberBetween(isNumber, min, max).not.number(37, min, max));
  });
});

TestingToBeMatchers.prototype.object()

new

Expects provided value to be an object. The method uses isObject() function from the @angular-package/type.

public object(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be an \`object\``
): this {
  this.toBe(is.object(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against the object of the specified range and the result of its check is passed to the expect() function of jasmine
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) an object

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isObject: any;
  beforeEach(() => isObject = {});
  testing.describe('to be or not to be', () => {
    testing.it(`an \`object\``, () => toBe.object(isObject).not.object(undefined));
  });
});

TestingToBeMatchers.prototype.objectKey()

new

Expects provided value to be an object with given keys. The method uses isObjectKey() function from the @angular-package/type.

public objectKey(
  value: any,
  key: Key | Key[],
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be an \`object\` with all given keys`
): this {
  this.toBe(is.objectKey(value, key), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against the object that contains given keys and the result of its check is passed to the expect() function of jasmine
key: Key | Key[] Property name of Key type or an array of property names of Key type of object from the provided value
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) an object with all given keys

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isObjectKey: any;
  beforeEach(() => isObjectKey = { firstName: '', lastName: ''});
  testing.describe('to be or not to be', () => {
    testing.it(`an \`object\` with all given keys`, () =>
      toBe.objectKey(isObjectKey, ['firstName', 'lastName']).not.objectKey(isObjectKey, ['noFirstName']));
  });
});

TestingToBeMatchers.prototype.objectKeyIn()

new

Expects provided value to be an object with given keys. The method uses isObjectKeyIn() function from the @angular-package/type.

public objectKeyIn(
  value: any,
  key: Key | Key[],
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be an \`object\` with all given keys`
): this {
  this.toBe(is.objectKeyIn(value, key), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against the object that contains given keys and the result of its check is passed to the expect() function of jasmine
key: Key | Key[] Property name of Key type or an array of property names of Key type of object from the provided value
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) an object with all given keys

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isObjectKeyIn: any;
  beforeEach(() => isObjectKeyIn = { get firstName(): string { return 'x '; }, lastName: ''});
  testing.describe('to be or not to be', () =>
    testing.it(`an \`object\` with all given keys`, () =>
      toBe.objectKeyIn(isObjectKeyIn, ['firstName', 'lastName']).not.objectKeyIn(isObjectKeyIn, ['noFirstName'])));
});

TestingToBeMatchers.prototype.objectKeys()

new

Expects provided value to be an object with some of the given keys. The method uses isObjectKeys() function from the @angular-package/type.

public objectKeys(
  value: any,
  keys: Key[],
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be an \`object\` with some of the given keys`
): this {
  this.toBe(is.objectKeys(value, ...keys), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against the object that contains some of the given keys and the result of its check is passed to the expect() function of jasmine
key: Key[] An array of property names of the Key type of object from the provided value
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) an object with some given keys

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isObjectKeys: any;
  beforeEach(() => isObjectKeys = { get firstName(): string { return 'x '; }, lastName: ''});
  testing.describe('to be or not to be', () =>
    testing.it(`an \`object\` with some of the given keys`, () =>
      toBe.objectKeys(isObjectKeys, ['firstName', 'lastName', 'noFirstName']).not.objectKeys(isObjectKeys, ['noFirstName'])));
});

TestingToBeMatchers.prototype.regexp()

new

Expects provided value to be RegExp. The method uses isRegExp() function from the @angular-package/type.

public regexp(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be \`regexp\``
): this {
  this.toBe(is.regexp(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against RegExp and the result of its check is passed to the expect() function of jasmine
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) RegExp

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isRegExp: any;
  beforeEach(() => isRegExp = /[]/g);

  testing.describe('to be or not to be', () =>
    testing.it(`\`RegExp\``, () =>
      toBe.regexp(isRegExp).not.regexp(undefined)));
});

TestingToBeMatchers.prototype.string()

new

Expects provided value to be string. The method uses isString() function from the @angular-package/type.

public string(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be a \`string\``
): this {
  this.toBe(is.string(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against a string and the result of its check is passed to the expect() function of jasmine
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) a string

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isString: any;
  beforeEach(() => isString = 'My new string');
  testing.describe('to be or not to be', () => {
    testing.it(`\`string\``, () => toBe.string(isString).not.string(undefined));
  });
});

TestingToBeMatchers.prototype.stringOfLength()

new

Expects provided value to be string of the length between the given minimum to maximum. The method uses isStringLength() function from the @angular-package/type.

public stringOfLength<Min extends number, Max extends number>(
  value: any,
  min: Min,
  max: Max,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be a \`string\` of the length between the given ${min} to ${max}`
): this {
  this.toBe(
    is.stringLength(value, min, max),
    expected,
    expectationFailOutput
  );
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against a string of the specified length and the result of its check is passed to the expect() function of jasmine
min: Min Minimum length of the given value of a number type
max: Max The maximum length of the given value of a number type
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) a string of the length between the given minimum to maximum

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isStringOfLength: any;
  let min: any;
  let max: any;
  beforeEach(() => {
    isStringOfLength = 'My new string, My new string';
    min = 26;
    max = 28;
  });
  testing.describe('to be or not to be', () => {
    testing.it(`a \`string\` between the given length`, () =>
      toBe.stringOfLength(isStringOfLength, min, max).not.stringOfLength(undefined, min, max));
  });
});

TestingToBeMatchers.prototype.symbol()

new

Expects provided value to be symbol. The method uses isSymbol() function from the @angular-package/type.

public symbol(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be a \`symbol\``
): this {
  this.toBe(is.symbol(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against a symbol and the result of its check is passed to the expect() function of jasmine
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) a symbol

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isSymbol: any;
  beforeEach(() => isSymbol = Symbol('firstName'));
  testing.describe('to be or not to be', () => 
    testing.it(`a \`symbol\``, () => toBe.symbol(isSymbol).not.symbol(undefined)));
});

TestingToBeMatchers.prototype.true()

new

Expects provided value to be true. The method uses isTrue() function from the @angular-package/type.

public true(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be \`true\``
): this {
  this.toBe(is.true(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against true and the result of its check is passed to the expect() function of jasmine
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) true

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isTrue: any;
  beforeEach(() => isTrue = true);
  testing.describe('to be or not to be', () =>
    testing.it(`\`true\``, () => toBe.true(isTrue).not.true(false)));
});

TestingToBeMatchers.prototype.undefined()

new

Expects provided value to be undefined. The method uses isUndefined() function from the @angular-package/type.

public undefined(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be \`undefined\``
): this {
  this.toBe(is.undefined(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against undefined and the result of its check is passed to the expect() function of jasmine
expected: boolean The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) undefined

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isUndefined: any;
  beforeEach(() => isUndefined = undefined);
  testing.describe('to be or not to be', () => 
    testing.it(`\`undefined\``, () => toBe.undefined(isUndefined).not.undefined(null)));
});

Constants

Constants prepared for testing purposes.

Array

/**
 * An `Array` of `bigint`.
 * Array: true
 * Object: true
 * typeOf(): "array"
 * typeof: "object"
 */
const TESTING_ARRAY_BIGINT = [
  TESTING_BIGINT,
  TESTING_BIGINT_CONSTRUCTOR,
  9007199254740991n,
];

/**
 * An `Array` of `boolean`.
 * Array: true
 * Object: true
 * typeOf(): "array"
 * typeof: "object"
 */
const TESTING_ARRAY_BOOLEAN = [
  true,
  false,
  TESTING_TRUE_INSTANCE,
  TESTING_FALSE_INSTANCE,
  false,
  TESTING_FALSE,
  TESTING_TRUE,
];

/**
 * An `Array` of `class`.
 * Array: true
 * Object: true
 * typeOf(): "array"
 * typeof: "object"
 */
const TESTING_ARRAY_CLASS = [
  new TestingClass(),
  new TestingClass(),
];

/**
 * An `Array` of `function`.
 * Array: true
 * Object: true
 * typeOf(): "array"
 * typeof: "object"
 */
const TESTING_ARRAY_FUNCTION = [
  TESTING_FUNCTION,
  TESTING_FUNCTION_CONSTRUCTOR,
  TESTING_FUNCTION_CONSTRUCTOR_PERSON,
  (x: number, y: string): any => x,
];

/**
 * An `Array` of `null`.
 * Array: true
 * Object: true
 * typeOf(): "array"
 * typeof: "object"
 */
const TESTING_ARRAY_NULL = [
  null,
  null,
  null,
  TESTING_NULL,
  TESTING_NULL,
];

/**
 * An `Array` of `number`.
 * Array: true
 * Object: true
 * typeOf(): "array"
 * typeof: "object"
 */
const TESTING_ARRAY_NUMBER = [
  1,
  2,
  3,
  4,
  7,
  10,
  1000,
  3000,
  151233,
  TESTING_NUMBER,
  TESTING_NUMBER_CONSTRUCTOR,
  TESTING_NUMBER_INSTANCE,
];

/**
 * An `Array` of `object`.
 * Array: true
 * Object: true
 * typeOf(): "array"
 * typeof: "object"
 */
const TESTING_ARRAY_OBJECT_ONE: Array<TestingObjectOne> = [
  { [TESTING_NUMBER]: 'my number', x: 3000 },
  { [TESTING_NUMBER]: 'my number', x: 1 },
];

/**
 * An `Array` of `string`.
 * Array: true
 * Object: true
 * typeOf(): "array"
 * typeof: "object"
 */
const TESTING_ARRAY_STRING = [
  TESTING_STRING,
  TESTING_STRING_CONSTRUCTOR,
  TESTING_STRING_INSTANCE,
  '!@#$%^&*()Company',
];

/**
 * An `Array` of `symbol`.
 * Array: true
 * Object: true
 * typeOf(): "array"
 * typeof: "object"
 */
const TESTING_ARRAY_SYMBOL_NUMBER = [
  TESTING_SYMBOL_NUMBER,
  Symbol(1005),
  Symbol(1002),
  Symbol(15),
  Symbol(1),
];

/**
 * An `Array` of `symbol`.
 * Array: true
 * Object: true
 * typeOf(): "array"
 * typeof: "object"
 */
const TESTING_ARRAY_SYMBOL_STRING = new Array([
  TESTING_SYMBOL_STRING,
  Symbol('String Symbol'),
  Symbol('String Symbol'),
  Symbol('String Symbol One'),
  Symbol('String Symbol Two'),
]);

/**
 * An `Array` of `undefined`.
 * Array: true
 * Object: true
 * typeOf(): "array"
 * typeof: "object"
 */
const TESTING_ARRAY_UNDEFINED: Array<undefined | unknown> = [
  undefined,
  undefined,
  undefined,
  TESTING_UNDEFINED,
  TESTING_NOT_DEFINED,
];

BigInt

/**
 * typeOf(): "bigint"
 * typeof: "bigint"
 */
const TESTING_BIGINT = BigInt('9007199254740991');

Boolean

/**
 * typeOf(): "boolean"
 * typeof: "boolean"
 */
const TESTING_FALSE = false;

/**
 * typeOf(): "boolean"
 * typeof: "boolean"
 */
const TESTING_TRUE = true;

/**
 * Boolean: true
 * Object: true
 * typeOf(): "boolean"
 * typeof: "object"
 */
// tslint:disable-next-line: ban-types no-construct
const TESTING_FALSE_INSTANCE = new Boolean(TESTING_FALSE);

/**
 * Boolean: true
 * Object: true
 * typeOf(): "boolean"
 * typeof: "object"
 */
// tslint:disable-next-line: ban-types no-construct
const TESTING_TRUE_INSTANCE = new Boolean(TESTING_TRUE);

Class

/**
 * Function: true
 * Object: true
 * class: true
 * typeOf(): "function"
 * typeof: "function"
 */
class TestingClass {

  /**
   * Property as `number` of a `string` type.
   */
  1030405027 = 'my new number';

  /**
   * Property as `number` of a `number` type.
   */
  5 = 27;

  /**
   * Property as `string` of a `string` type.
   */
  firstName = 'My name';

  /**
   * Property as `number` of a `string` type.
   */
  surname = 'Surname';

  /**
   * Property as `number` of a `number` type.
   */
  age = TESTING_NUMBER;

  /**
   * Property as `string` of a `string` type.
   */
  city = TESTING_STRING;

  /**
   * Getter as `number` of a `number` type.
   */
  get [TESTING_NUMBER](): number {
    return this.age;
  }

  /**
   * Getter as `string` of a `string` type.
   */
  get [TESTING_STRING](): string {
    return this.city;
  }

  /**
   * Getter as `symbol number` of a `number` type.
   */
  get [TESTING_SYMBOL_NUMBER](): number {
    return this.age;
  }

  /**
   * Getter as `symbol string` of a `string` type.
   */
  get [TESTING_SYMBOL_STRING](): string {
    return this.city;
  }
}

/**
 * Object: true
 * typeOf(): "object"
 * typeof: "object"
 */
const TESTING_CLASS = new TestingClass();

Date

/**
 * Date: true
 * Object: true
 * typeOf(): "date"
 * typeof: "object"
 */
const TESTING_DATE = new Date(1995, 11, 17, 3, 24, 0);

Function

/**
 * Function: true
 * Object: true
 * function: true
 * typeOf(): "function"
 * typeof: "function"
 */
const TESTING_FUNCTION = (x: number, y: string): any => x + y;

/**
 * Function: true
 * Object: true
 * function: true
 * typeOf(): "function"
 * typeof: "function"
 */
const TESTING_FUNCTION_CONSTRUCTOR = function(
  this: any,
  ...args: any[]
): any {
  if (args) {
    args.forEach((arg, index: number) => (this[index] = arg[index]));
  }
  return this;
};

/**
 * Function: true
 * Object: true
 * function: true
 * typeOf(): "function"
 * typeof: "function"
 */
const TESTING_FUNCTION_CONSTRUCTOR_PERSON = function(
  this: TestingPerson,
  ...args: any[]
): TestingPerson {
  if (args) {
    this.firstName = args[0];
    this.surname = args[1];
    this.age = args[2];
  }
  return this;
};

null

/**
 * typeOf(): "null"
 * typeof: "object"
 */
const TESTING_NULL = null;

Number

/**
 * typeOf(): "number"
 * typeof: "number"
 */
const TESTING_NUMBER = 10304050;

/**
 * typeOf(): "number"
 * typeof: "number"
 */
const TESTING_NUMBER_CONSTRUCTOR = Number(TESTING_NUMBER);

/**
 * Number: true
 * Object: true
 * typeOf(): "number"
 * typeof: "object"
 */
// tslint:disable-next-line: ban-types no-construct
const TESTING_NUMBER_INSTANCE: Number = new Number(
  TESTING_NUMBER
);

Object

/**
 * Object: true,
 * typeOf(): "object",
 * typeof: "object"
 */
const TESTING_OBJECT_ONE: TestingObjectOne = {
  'key as string': true,
  1030405027: 'key is number',
  5: 'key is also number',
  [TESTING_NUMBER]: 'key is number',
  [TESTING_STRING]: 'key is string',
  [TESTING_SYMBOL_NUMBER]: 'key is symbol number',
  [TESTING_SYMBOL_STRING]: 6,
  x: 3000,
};

/**
 * Object: true,
 * typeOf(): "object",
 * typeof: "object"
 */
const TESTING_OBJECT_ONE_NEW = new Object(TESTING_OBJECT_ONE);

RegExp

/**
 * RegExp: true,
 * Object: true,
 * typeOf(): "regexp",
 * typeof: "object"
 */
const TESTING_PATTERN = /[^a-zA-Z0-9]/g;

String

/**
 * typeOf(): "string"
 * typeof: "string"
 */
const TESTING_STRING = '!@#$%^&*()Company';

/**
 * typeOf(): "string"
 * typeof: "string"
 */
const TESTING_STRING_CONSTRUCTOR = String(TESTING_STRING);

/**
 * Object: true
 * String: true
 * typeOf(): "string"
 * typeof: "object"
 */
// tslint:disable-next-line: ban-types no-construct
const TESTING_STRING_INSTANCE = new String(
  TESTING_STRING
);

Symbol

/**
 * typeOf(): "symbol"
 * typeof: "symbol"
 */
const TESTING_SYMBOL_NUMBER: unique symbol = Symbol(
  TESTING_NUMBER
);

/**
 * typeOf(): "symbol"
 * typeof: "symbol"
 */
const TESTING_SYMBOL_STRING: unique symbol = Symbol(
  TESTING_STRING
);

undefined

/**
 * typeOf(): "undefined"
 * typeof: "undefined"
 */
const TESTING_UNDEFINED = undefined;

GIT

Commit

Versioning

Semantic Versioning 2.0.0

Given a version number MAJOR.MINOR.PATCH, increment the:

  • MAJOR version when you make incompatible API changes,
  • MINOR version when you add functionality in a backwards-compatible manner, and
  • PATCH version when you make backwards-compatible bug fixes.

Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.

FAQ How should I deal with revisions in the 0.y.z initial development phase?

The simplest thing to do is start your initial development release at 0.1.0 and then increment the minor version for each subsequent release.

How do I know when to release 1.0.0?

If your software is being used in production, it should probably already be 1.0.0. If you have a stable API on which users have come to depend, you should be 1.0.0. If you’re worrying a lot about backwards compatibility, you should probably already be 1.0.0.

License

MIT © angular-package (license)

About

Jasmine unit testing wrapper with additional custom testing features.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published

Contributors 2

  •  
  •