JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 187
  • Score
    100M100P100Q92518F
  • License ISC

a chai plugin for type assertions, support typescript

Package Exports

  • chai-asserttype-extra

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (chai-asserttype-extra) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

chai-asserttype

a chai plugin for type assertions, support typescript

Installation

npm install chai chai-asserttype-extra

install as chai plug-in

const ChaiPluginAssertType = require('chai-asserttype-extra');
import ChaiPluginAssertType = require('chai-asserttype-extra');
import ChaiPluginAssertType from 'chai-asserttype-extra';
import { ChaiPlugin as ChaiPluginAssertType } from 'chai-asserttype-extra';

choose one of ur fav way

when use .install will try make current chai support to new method in typescript, make without use @ts-ignore

const chai = ChaiPluginAssertType.install();
const chai = ChaiPluginAssertType.install(require('chai'));
const chai = require('chai-asserttype-extra').install()
const chai = require('chai');
chai.use(ChaiPluginAssertType);
const chai = require('chai');
chai.use(ChaiPluginAssertType);

Usage

this usage copy from GaneshSPatil/chai-asserttype

support both of .xxx() and .xxx

ChaiPluginAssertType.list()

console.log(ChaiPluginAssertType.list());
/*
[ 'array',
  'boolean',
  'date',
  'float',
  'function',
  'integer',
  'null',
  'number',
  'object',
  'regexp',
  'string',
  'undefined' ]
*/

Number

Asserts that type of actual is Number.

expect(1).to.be.number();
expect(0).to.be.number();
expect(-1).to.be.number();
expect(63465789908753).to.be.number();
expect(27.11).to.be.number();

expect(1).to.be.number;
expect(0).to.be.number;
expect(-1).to.be.number;
expect(63465789908753).to.be.number;
expect(27.11).to.be.number;

integer

expect(27).to.be.integer();
expect(27).to.be.integer;

float

expect(27.11).to.be.float();
expect(27.11).to.be.float;

String

Asserts that type of actual is String.

expect('').to.be.string();
expect('foobar').to.be.string();

Boolean

Asserts that type of actual is Boolean.

expect(true).to.be.boolean();
expect(false).to.be.boolean();

Object

Asserts that type of actual is Object.

expect({}).to.be.object();

Array

Asserts that type of actual is Array.

expect([]).to.be.array();
expect([1, 2, 3]).to.be.array();

Date

Asserts that type of actual is date.

expect(new Date()).to.be.date();

Function

Asserts that type of actual is Function.

expect(() => true).to.be.function();