@angular-package/testing

Support for testing other packages.

Usage no npm install needed!

<script type="module">
  import angularPackageTesting from 'https://cdn.skypack.dev/@angular-package/testing';
</script>

README

Packages

Package Description Status
[callback][callback-github-readme] Manages the callback [function][js-function]. [![npm version][callback-npm-badge-png]][callback-npm-badge]
[change-detection][cd-github-readme] Improves application performance. [![npm version][cd-npm-badge-png]][cd-npm-badge]
[component-loader][cl-github-readme] Handles dynamic loading components. [![npm version][cl-npm-badge-png]][cl-npm-badge]
[core][core-github-readme] Core features. [![npm version][core-npm-badge-png]][core-npm-badge]
[error][error-github-readme] Manages an [Error][js-error]. [![npm version][error-npm-badge-png]][error-npm-badge]
[name][name-github-readme] The name with prefix and suffix. [![npm version][name-npm-badge-png]][name-npm-badge]
[preferences][preferences-github-readme] Preferences, settings, options, configuration and setup in steps. [![npm version][preferences-npm-badge-png]][preferences-npm-badge]
[prism][prism-github-readme] [Prism][prism-js] highlighter module. [![npm version][prism-npm-badge-png]][prism-npm-badge]
[property][property-github-readme] Handles object properties. [![npm version][property-npm-badge-png]][property-npm-badge]
[range][range-github-readme] The range between a minimum and maximum. [![npm version][range-npm-badge-png]][range-npm-badge]
[reactive][reactive-github-readme] Automatize the process of creating some rxjs features. [![npm version][reactive-npm-badge-png]][reactive-npm-badge]
[storage][storage-github-readme] The storage of data under allowed names. [![npm version][storage-npm-badge-png]][storage-npm-badge]
[tag][tag-github-readme] Any tag with optional attributes. [![npm version][tag-npm-badge-png]][tag-npm-badge]
[testing][testing-github-readme] Support for testing other packages. [![npm version][testing-npm-badge-png]][testing-npm-badge]
[text][text-github-readme] Text on the template with replaceable tags. [![npm version][text-npm-badge-png]][text-npm-badge]
[type][type-github-readme] Common types, type guards, and type checkers. [![npm version][type-npm-badge-png]][type-npm-badge]
[ui][ui-github-readme] User interface. In Progress
[wrapper][wrapper-github-readme] Wrap the text with the opening and closing chars. [![npm version][wrapper-npm-badge-png]][wrapper-npm-badge]

Click on the package name to visit its GitHub page.


angular-package/testing

Support for testing other packages.

[![Gitter][gitter-badge]][gitter-chat] [![Discord][discord-badge]][discord-channel] [![Twitter][twitter-badge]][twitter-follow]

[![npm version][testing-npm-badge-svg]][testing-npm-badge]

[![GitHub issues][testing-badge-issues]][testing-issues] [![GitHub forks][testing-badge-forks]][testing-forks] [![GitHub stars][testing-badge-stars]][testing-stars] [![GitHub license][testing-badge-license]][testing-license]

[![GitHub sponsors][github-badge-sponsor]][github-sponsor-link] [![Support me on Patreon][patreon-badge]][patreon-link]


Table of contents


Basic concepts

Checks

It's 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

It's a combination of both above, constrains the type of the parameter in the code editor, and checks its provided argument.

Defines

Returns defined value from a method of an object.
Defines new value in an object and returns a defined value.

Gets

Returns a value from an object.

Sets

Adds or updates an element with a specified key and a value to an object and returns an object.


Skeleton

This package was built by the [library skeleton][skeleton] which was generated with Angular CLI version 12.2.5.

Copy this package to the packages/testing folder of the [library skeleton][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

Api

// Main.
import {
  // Class.
  Testing,
  TestingToBeMatchers,
} from '@angular-package/testing';
// Helper functions.
import {
  // Function.
  randomNumber,
  randomString,
} from '@angular-package/testing';
// Helper constants.
import {
  // Example class for testing.
  TestingClass,
  TestingPerson,

  // Array.
  TESTING_ARRAY_BIGINT,
  TESTING_ARRAY_BOOLEAN,
  TESTING_ARRAY_CLASS,
  TESTING_ARRAY_FUNCTION,
  TESTING_ARRAY_NULL,
  TESTING_ARRAY_NUMBER,
  TESTING_ARRAY_OBJECT_ONE,
  TESTING_ARRAY_STRING,
  TESTING_ARRAY_SYMBOL_NUMBER,
  TESTING_ARRAY_SYMBOL_STRING,
  TESTING_ARRAY_UNDEFINED,
  // BigInt
  TESTING_BIGINT,
  // Class.
  TESTING_CLASS,
  TESTING_PERSON,
  // Date.
  TESTING_DATE,
  // Boolean.
  TESTING_FALSE,
  TESTING_FALSE_INSTANCE,
  TESTING_TRUE,
  TESTING_TRUE_INSTANCE,
  // Function.
  TESTING_FUNCTION,
  TESTING_FUNCTION_CONSTRUCTOR,
  TESTING_FUNCTION_CONSTRUCTOR_PERSON,
  // null.
  TESTING_NULL,
  // Number.
  TESTING_NUMBER,
  TESTING_NUMBER_CONSTRUCTOR,
  TESTING_NUMBER_INSTANCE,
  // Object.
  TESTING_OBJECT,
  // RegExp.
  TESTING_REGEXP,
  // String.
  TESTING_STRING,
  TESTING_STRING_CONSTRUCTOR,
  TESTING_STRING_INSTANCE,
  // Symbol.
  TESTING_SYMBOL_NUMBER,
  TESTING_SYMBOL_STRING,
  // Undefined.
  TESTING_UNDEFINED,
} from '@angular-package/testing';
import {
  // Interface. 
  TestingObject,
  TestingPersonShape
} from '@angular-package/testing';

Instance of

Possible names of javascript objects that can be checked by the [instanceof][js-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][js-classes] to support testing.

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

Static methods:

Testing. Description
defineDescribe() Defines the wrapper [function][js-function] of the [describe()][jasmine-describe] function of jasmine with the ability to decide its execution.
defineIt() Defines the wrapper [function][js-function] of the [it()][jasmine-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 public methods:

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

Testing static methods

Testing.defineDescribe()

Defines the wrapper [function][js-function] of the [describe()][jasmine-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][js-function] that contains the [describe()][jasmine-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][js-function] of the [it()][jasmine-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()][jasmine-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 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).

constructor(
  allowDescribe: boolean,
  allowIt: boolean,
  executable?: ExecutableTests
) {
  super(allowDescribe, allowIt, executable);
}

Parameters:

Name: type Description
allowDescribe: boolean Allow executing describe() methods.
allowIt: boolean Allow executing it() methods.
executable?: ExecutableTests An optional [object][js-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 instance methods

Testing.prototype.describe()

Executes defined [describe()][jasmine-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][js-boolean] type value to decide whether or not execute defined [describe()][jasmine-describe] of jasmine function.

Returns:

The return value is an instance of 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()][jasmine-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][js-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][js-boolean] type value to decide whether or not execute defined [it()][jasmine-it] of jasmine function.

Returns:

The return value is an instance of 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()

[![update]][testing-github-changelog]

Executes the spec on a state true from the execute expecting the provided value to be the given expected value. The execute parameter is optional because, by default it takes its value from the global allowIt parameter specified in the constructor.

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][js-number] when adding [counter].
value: Value The value of any type passed to the [expect()][jasmine-expect] function of jasmine.
expected: any The value of any type passed to the toBe() method of [jasmine.Matchers][jasmine-matchers].
execute?: boolean An optional parameter that specifies whether the spec is to be executed. By default it takes its value from the global allowIt parameter specified in the constructor.

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,
  false // Execute `it()` method globally is off.
);
/**
 * toBe().
 */
testing.describe('string', () => {
  testing.toBe(
    `Checks the value against the string`,
    is.stringType('my name'),
    true,
    true  // Even if globally executing the method `it()` is off, `execute` parameter as `true` executes this spec.
  );
});

Testing.prototype.toBeBigInt()

[![update]][testing-github-changelog]

Executes the spec on a state true from the execute expecting the provided value to be a [bigint][js-bigint] type on the expected of true. The method uses isBigInt() function of [@angular-package/type][type-github-readme].

public toBeBigInt<Value>(
  value: Value,
  execute?: boolean,
  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 An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be a bigint type'.
expected: boolean Expects the result of the expectation to 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()

[![update]][testing-github-changelog]

Executes the spec on a state true from the execute expecting the provided value to be of a [boolean][js-boolean] type on the expected of true. The method uses isBooleanType() function of [@angular-package/type][type-github-readme].

public toBeBooleanType<Value>(
  value: Value,
  execute?: boolean,
  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 An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be of a boolean type'.
expected: boolean Expects the result of the expectation to 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][js-classes] on the expected of true. The method uses isClass() function of [@angular-package/type][type-github-readme].

public toBeClass<Value>(
  value: Value,
  execute?: boolean,
  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 An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be a class'.
expected: boolean Expects the result of the expectation to 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][js-array] on the expected of true. The method uses isArray() function of [@angular-package/type][type-github-readme].

public toBeInstanceOfArray<Value>(
  value: Value,
  execute?: boolean,
  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 An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be an instance of an Array'.
expected: boolean Expects the result of the expectation to 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][js-boolean] on the expected of true. The method uses isBooleanObject() function of [@angular-package/type][type-github-readme].

public toBeInstanceOfBoolean<Value>(
  value: Value,
  execute?: boolean,
  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 An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be an instance of an Boolean'.
expected: boolean Expects the result of the expectation to 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][js-date] on the expected of true. The method uses isDate() function of [@angular-package/type][type-github-readme].

public toBeInstanceOfDate<Value>(
  value: Value,
  execute?: boolean,
  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 An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be an instance of Date'.
expected: boolean Expects the result of the expectation to 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][js-error] the expected of true.

public toBeInstanceOfError<Value>(
  value: Value,
  execute?: boolean,
  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 An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be an instance of an Error'.
expected: boolean Expects the result of the expectation to 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][js-function] on the expected of true.

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

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be an instance of a Function'.
expected: boolean Expects the result of the expectation to 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][js-map] on the expected of true.

public toBeInstanceOfMap<Value>(
  value: Value,
  execute?: boolean,
  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 An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be an instance of a Map'.
expected: boolean Expects the result of the expectation to 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][js-number] on the expected of true. The method uses isNumberObject() function of [@angular-package/type][type-github-readme].

public toBeInstanceOfNumber<Value>(
  value: Value,
  execute?: boolean,
  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 An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be an instance of a Number'.
expected: boolean Expects the result of the expectation to 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][js-object] on the expected of true. The method uses isObject() function of [@angular-package/type][type-github-readme].

public toBeInstanceOfObject<Value>(
  value: Value,
  execute?: boolean,
  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 An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be an instance of an Object'.
expected: boolean Expects the result of the expectation to 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][js-promise] on the expected of true.

public toBeInstanceOfPromise<Value>(
  value: Value,
  execute?: boolean,
  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 An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be an instance of Promise'.
expected: boolean Expects the result of the expectation to 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][js-rangeerror] on the expected state.

public toBeInstanceOfRangeError<Value>(
  value: Value,
  execute?: boolean,
  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 An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be an instance of RangeError'.
expected: boolean Expects the result of the expectation to 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][js-referenceerror] on the expected of true.

public toBeInstanceOfReferenceError<Value>(
  value: Value,
  execute?: boolean,
  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 An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be an instance of ReferenceError'.
expected: boolean Expects the result of the expectation to 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][js-regexp] on the expected of true. The method uses isRegExp() function of [@angular-package/type][type-github-readme].

public toBeInstanceOfRegExp<Value>(
  value: Value,
  execute?: boolean,
  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 An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be an instance of RegExp'.
expected: boolean Expects the result of the expectation to 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][js-set] on the expected of true.

public toBeInstanceOfSet<Value>(
  value: Value,
  execute?: boolean,
  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 An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be an instance of Set'.
expected: boolean Expects the result of the expectation to 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][js-storage] on the expected of true.

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

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be an instance of Storage'.
expected: boolean Expects the result of the expectation to 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][js-string] on the expected of true. The method uses isStringObject() function of [@angular-package/type][type-github-readme].

public toBeInstanceOfString<Value>(
  value: Value,
  execute?: boolean,
  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 An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be an instance of a String'.
expected: boolean Expects the result of the expectation to 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][js-syntaxerror] on the expected of true.

public toBeInstanceOfSyntaxError<Value>(
  value: Value,
  execute?: boolean,
  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 An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be an instance of SyntaxError'.
expected: boolean Expects the result of the expectation to 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 [TypeError][js-typeerror] on the expected of true.

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

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be an instance of SyntaxError'.
expected: boolean Expects the result of the expectation to 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][js-urlerror] on the expected of true.

public toBeInstanceOfURIError<Value>(
  value: Value,
  execute?: boolean,
  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 An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be an instance of URIError'.
expected: boolean Expects the result of the expectation to 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][js-weakset] on the expected of true.

public toBeInstanceOfWeakSet<Value>(
  value: Value,
  execute?: boolean,
  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 An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be an instance of WeakSet'.
expected: boolean Expects the result of the expectation to 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][js-null] on the expected of true. The method uses isNull() function of [@angular-package/type][type-github-readme].

public toBeNull<Value>(
  value: Value,
  execute?: boolean,
  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 An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be null'.
expected: boolean Expects the result of the expectation to 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][js-number] type on the expected of true. The method uses isNumberType() function of [@angular-package/type][type-github-readme].

public toBeNull<Value>(
  value: Value,
  execute?: boolean,
  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 An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the [karma][karma], which by default is set to 'The value must be of a number type'.
expected: boolean Expects the result of the expectation to 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][js-string] type on the expected of true. The method uses isStringType() function from the [@angular-package/type][type-github-readme].

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