@leyman/expect 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Jacob Ley
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,52 @@
1
- # Temporary Holding Version
1
+ <div style="text-align:center">
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ # @leyman/expect
4
+
5
+ Chai's expect and assert with chai-as-promised registered, as one ESM import, so async assertions work in any test file without setup.
6
+
7
+ [![npm package](https://badge.fury.io/js/@leyman%2Fexpect.svg)](https://www.npmjs.com/package/@leyman/expect)
8
+ [![License](https://img.shields.io/npm/l/@leyman/expect.svg)](https://github.com/JacobLey/leyman/blob/main/leyman/expect/LICENSE)
9
+
10
+ </div>
11
+
12
+ - **No setup file** — importing it registers chai-as-promised, so `rejectedWith` and `eventually` work in any test, whatever the runner or its config.
13
+ - **One dependency instead of four** — `chai`, `chai-as-promised` and both `@types` packages come with it.
14
+ - **Types included** — the declarations load chai-as-promised's type augmentations, so `.rejectedWith` type-checks without importing it yourself.
15
+
16
+ ## Contents
17
+
18
+ - [Install](#install)
19
+ - [Example](#example)
20
+ - [Usage](#usage)
21
+ - [API](#api)
22
+
23
+ ## Install
24
+
25
+ ```sh
26
+ npm i -D @leyman/expect
27
+ ```
28
+
29
+ ## Example
30
+
31
+ ```ts
32
+ import { expect } from '@leyman/expect';
33
+
34
+ const thrown: unknown = await expect(myPromise()).to.be.rejectedWith(Error);
35
+ expect(thrown).to.have.property('message').that.includes('<ERROR>');
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ The package is ESM only. Importing it calls `chai.use(chaiAsPromised)` once, on the `chai` it depends on, so it is a module with side effects. If your tests import `chai` directly too, make sure it resolves to the same copy, or that copy won't have chai-as-promised registered.
41
+
42
+ It is meant for tests: depend on it as a dev dependency.
43
+
44
+ ## API
45
+
46
+ ### `expect`, `assert`
47
+
48
+ Chai's own `expect` and `assert`, re-exported after chai-as-promised is registered. See [Chai's docs](https://www.chaijs.com/api/bdd/) and [chai-as-promised's](https://github.com/chaijs/chai-as-promised#readme).
49
+
50
+ ### `ChaiAsPromised`
51
+
52
+ The type of the chai-as-promised plugin. Exported so the declarations import chai-as-promised, which is what loads its augmentations of Chai's types.
@@ -0,0 +1,11 @@
1
+ import chaiAsPromised from 'chai-as-promised';
2
+ /**
3
+ * Chai's `assert` and `expect`, with `chai-as-promised` already registered.
4
+ */
5
+ export { assert, expect } from 'chai';
6
+ /**
7
+ * Exported so emitted declarations import `chai-as-promised`, which loads its type augmentations
8
+ * (e.g. `rejectedWith`) for consumers.
9
+ */
10
+ export type ChaiAsPromised = typeof chaiAsPromised;
11
+ //# sourceMappingURL=expect.d.ts.map
package/dist/expect.js ADDED
@@ -0,0 +1,6 @@
1
+ import { use } from 'chai';
2
+ import chaiAsPromised from 'chai-as-promised';
3
+ use(chaiAsPromised);
4
+ export { assert, expect } from 'chai';
5
+
6
+ //# sourceMappingURL=expect.js.map
package/package.json CHANGED
@@ -1,6 +1,60 @@
1
1
  {
2
2
  "name": "@leyman/expect",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Chai's expect and assert with chai-as-promised registered, as one ESM import, so async assertions work in any test file without setup.",
5
+ "engines": {
6
+ "node": ">=22"
7
+ },
8
+ "type": "module",
9
+ "author": "JacobLey",
10
+ "license": "MIT",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/JacobLey/leyman.git",
14
+ "directory": "leyman/expect"
15
+ },
16
+ "homepage": "https://github.com/JacobLey/leyman/tree/main/leyman/expect#readme",
17
+ "bugs": {
18
+ "url": "https://github.com/JacobLey/leyman/issues"
19
+ },
20
+ "keywords": [
21
+ "chai",
22
+ "chai-as-promised",
23
+ "expect",
24
+ "assert",
25
+ "assertions",
26
+ "testing",
27
+ "mocha",
28
+ "esm",
29
+ "typescript"
30
+ ],
31
+ "sideEffects": true,
32
+ "exports": {
33
+ ".": "./dist/expect.js"
34
+ },
35
+ "files": [
36
+ "dist",
37
+ "!dist/**/*.map",
38
+ "!dist/tsconfig.tsbuildinfo"
39
+ ],
40
+ "dependencies": {
41
+ "@types/chai": "^5.2.3",
42
+ "@types/chai-as-promised": "^8.0.2",
43
+ "chai": "^6.2.2",
44
+ "chai-as-promised": "^8.0.2"
45
+ },
46
+ "devDependencies": {
47
+ "@biomejs/biome": "^2.6.4",
48
+ "@leyman/configs": "^0.1.0",
49
+ "@leyman/eslint-config": "^0.1.0",
50
+ "@swc/cli": "^0.8.1",
51
+ "@swc/core": "^1.16.20",
52
+ "@types/mocha": "^10.0.10",
53
+ "@types/node": "^22.20.5",
54
+ "@typescript/native": "npm:typescript@^7.0.2",
55
+ "c8": "^12.0.0",
56
+ "eslint": "^10.13.0",
57
+ "mocha": "^12.0.3",
58
+ "typescript": "npm:@typescript/typescript6@^6.0.2"
59
+ }
6
60
  }