2.0.14 • Published 6 months ago

chai-asserttype-extra v2.0.14

Weekly downloads
253
License
ISC
Repository
github
Last release
6 months ago

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();
2.0.14

6 months ago

2.0.13

1 year ago

2.0.11

1 year ago

2.0.12

1 year ago

2.0.9

2 years ago

2.0.10

2 years ago

2.0.7

2 years ago

2.0.8

2 years ago

2.0.5

2 years ago

2.0.6

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.4

2 years ago

2.0.1

2 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago