# @lazy-random/expect

> 預先載入 chai-asserttype-extra 外掛 (Plugin) 的 Chai 斷言 (Assertion) 封裝套件，讓專案不必在每個測試檔重複呼叫 chai.use()

Latest version **2.0.1** (published 2026-10-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install @lazy-random/expect
pnpm add @lazy-random/expect
yarn add @lazy-random/expect
bun add @lazy-random/expect
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2026-10-05 |
| First published | 2021-12-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 31.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | bluelovers |
| Maintainers | bluelovers |
| Keywords | assert, assertion, chai, chai-asserttype-extra, expect, lazy-random, plugin, test, testing, create-by-yarn-tool, create-by-tsdx |

## Links

- npm: https://www.npmjs.com/package/@lazy-random/expect
- Repository: https://github.com/bluelovers/ws-random
- Homepage: https://github.com/bluelovers/ws-random/tree/master/packages/@lazy-random/expect#readme
- Issues: https://github.com/bluelovers/ws-random/issues
- npm.io page: https://npm.io/package/@lazy-random/expect

## Dependencies (2)

- [chai](https://npm.io/package/chai.md) ^6.3.0
- [chai-asserttype-extra](https://npm.io/package/chai-asserttype-extra.md) ^2.0.15

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2026-10-05
- 1.0.15 — 2023-11-19
- 1.0.13 — 2022-10-29
- 1.0.12 — 2022-01-03
- 1.0.10 — 2021-12-21
- 1.0.5 — 2021-12-12

## README

# @lazy-random/expect

預先載入 [chai-asserttype-extra](https://www.npmjs.com/package/chai-asserttype-extra) 外掛 (Plugin) 的 Chai 斷言 (Assertion) 封裝套件，讓專案不必在每個測試檔重複呼叫 `chai.use()`。

## 特色 (Features)

- 匯出已套用 `chai-asserttype-extra` 外掛的 `expect` 與 `assert`
- 同時提供預設匯出 (Default Export) 與具名匯出 (Named Export)，依使用習慣選擇
- 內建 TypeScript 型別宣告 (Type Declarations)

## 安裝 (Installation)

```bash
yarn add @lazy-random/expect
yarn-tool add @lazy-random/expect
yt add @lazy-random/expect
```

## 使用方式 (Usage)

```ts
import expect, { assert, expect as namedExpect } from '@lazy-random/expect';

// 使用預設匯出的 expect，可直接使用 chai-asserttype-extra 提供的斷言方法
expect(1).to.be.a('number');
expect([1, 2, 3]).to.be an array.of.length(3);

// 具名匯出的 assert 同樣已套用外掛
assert.strictEqual(1, 1);
```

```js
const expect = require('@lazy-random/expect').default;
const { assert } = require('@lazy-random/expect');
```

## API 文件 (API Documentation)

| 匯出 (Export) | 型別 (Type) | 說明 (Description) |
| --- | --- | --- |
| `expect`（預設匯出） | `Chai.ExpectStatic` | 已套用 `chai-asserttype-extra` 外掛的 `expect` 斷言函式 |
| `expect`（具名匯出） | `Chai.ExpectStatic` | 同上，與預設匯出為同一個物件 |
| `assert` | `Chai.AssertStatic` | 已套用 `chai-asserttype-extra` 外掛的 `assert` 斷言物件 |

> `chai-asserttype-extra` 所提供的進階型別斷言方法，請參閱該套件的文件。

## 開發 (Development)

```bash
pnpm run build
pnpm run test:jest
```

## 變更日誌 (Changelog)

詳見 [CHANGELOG.md](./CHANGELOG.md)。

## 相關資源 (Related Resources)

- [chai](https://www.chaijs.com/)
- [chai-asserttype-extra](https://www.npmjs.com/package/chai-asserttype-extra)

---
_Source: https://npm.io/package/@lazy-random/expect · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
