Skip to content

Commit 6142c00

Browse files
committed
Add test-utils package
1 parent aa46ee9 commit 6142c00

36 files changed

Lines changed: 3965 additions & 2 deletions

README-DEV.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,26 @@ Matterbridge exports from:
191191

192192
- Vitest Matter test helpers.
193193

194+
**"matterbridge/test-utils"**
195+
196+
- Common test utilities shared by all test runners.
197+
198+
**"matterbridge/test-utils/matter"**
199+
200+
- Common Matter test helpers shared by all test runners.
201+
202+
**"matterbridge/test-utils/jest"**
203+
204+
- Jest-specific test utilities and Matter test helpers.
205+
206+
**"matterbridge/test-utils/vitest"**
207+
208+
- Vitest-specific test utilities and Matter test helpers.
209+
210+
**"matterbridge/test-utils/buntest"**
211+
212+
- Bun test-specific utilities and Matter test helpers.
213+
194214
**"matterbridge/matter"**
195215

196216
- All relevant matter.js exports.

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,7 @@ Matterbridge is published as an npm **monorepo**. The package you install, `matt
784784
| `packages/types` | `@matterbridge/types` | Shared TypeScript types and constants. |
785785
| `packages/jest-utils` | `@matterbridge/jest-utils` | Jest test-environment setup helpers. |
786786
| `packages/vitest-utils` | `@matterbridge/vitest-utils` | Vitest test-environment setup helpers. |
787+
| `packages/test-utils` | `@matterbridge/test-utils` | Common test helpers with Matter, Jest, Vitest and Bun test-specific exports. |
787788

788789
## Imports graph
789790

@@ -798,9 +799,11 @@ graph TD
798799
utils["@matterbridge/utils"]
799800
types["@matterbridge/types"]
800801
vitestutils["@matterbridge/vitest-utils"]
802+
testutils["@matterbridge/test-utils"]
801803
802804
matterbridge --> core
803805
matterbridge --> vitestutils
806+
matterbridge --> testutils
804807
805808
core --> thread
806809
core --> dgram
@@ -812,13 +815,15 @@ graph TD
812815
dgram --> utils
813816
vitestutils --> utils
814817
vitestutils --> types
818+
testutils --> utils
819+
testutils --> types
815820
```
816821

817822
The graph is acyclic and layered:
818823

819824
- **Foundation (no internal dependencies):** `@matterbridge/types`, `@matterbridge/utils`.
820825
- **Networking & workers:** `@matterbridge/dgram` (→ `utils`), `@matterbridge/thread` (→ `utils`, `types`).
821-
- **Test helpers:** `@matterbridge/jest-utils` and `@matterbridge/vitest-utils` (→ `utils`, `types`).
826+
- **Test helpers:** `@matterbridge/jest-utils`, `@matterbridge/vitest-utils` and `@matterbridge/test-utils` (→ `utils`, `types`).
822827
- **Core:** `@matterbridge/core` (→ `dgram`, `thread`, `utils`, `types`).
823828
- **Top level:** `matterbridge` declares all scoped packages as direct dependencies; `core` pulls in the rest transitively.
824829

docs/README-DEV.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,26 @@ <h2 id="guidelines-on-importsexports">Guidelines on imports/exports</h2>
353353
<ul>
354354
<li>Vitest Matter test helpers.</li>
355355
</ul>
356+
<p><strong>&quot;matterbridge/test-utils&quot;</strong></p>
357+
<ul>
358+
<li>Common test utilities shared by all test runners.</li>
359+
</ul>
360+
<p><strong>&quot;matterbridge/test-utils/matter&quot;</strong></p>
361+
<ul>
362+
<li>Common Matter test helpers shared by all test runners.</li>
363+
</ul>
364+
<p><strong>&quot;matterbridge/test-utils/jest&quot;</strong></p>
365+
<ul>
366+
<li>Jest-specific test utilities and Matter test helpers.</li>
367+
</ul>
368+
<p><strong>&quot;matterbridge/test-utils/vitest&quot;</strong></p>
369+
<ul>
370+
<li>Vitest-specific test utilities and Matter test helpers.</li>
371+
</ul>
372+
<p><strong>&quot;matterbridge/test-utils/buntest&quot;</strong></p>
373+
<ul>
374+
<li>Bun test-specific utilities and Matter test helpers.</li>
375+
</ul>
356376
<p><strong>&quot;matterbridge/matter&quot;</strong></p>
357377
<ul>
358378
<li>All relevant matter.js exports.</li>

docs/README.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,11 @@ <h1 id="package-structure">Package structure</h1>
628628
<td><code>@matterbridge/vitest-utils</code></td>
629629
<td>Vitest test-environment setup helpers.</td>
630630
</tr>
631+
<tr>
632+
<td><code>packages/test-utils</code></td>
633+
<td><code>@matterbridge/test-utils</code></td>
634+
<td>Common test helpers with Matter, Jest, Vitest and Bun test-specific exports.</td>
635+
</tr>
631636
</tbody></table>
632637
<h2 id="imports-graph">Imports graph</h2>
633638
<p>Runtime dependencies between the published packages.</p>
@@ -639,9 +644,11 @@ <h2 id="imports-graph">Imports graph</h2>
639644
utils[&quot;@matterbridge/utils&quot;]
640645
types[&quot;@matterbridge/types&quot;]
641646
vitestutils[&quot;@matterbridge/vitest-utils&quot;]
647+
testutils[&quot;@matterbridge/test-utils&quot;]
642648

643649
matterbridge --&gt; core
644650
matterbridge --&gt; vitestutils
651+
matterbridge --&gt; testutils
645652

646653
core --&gt; thread
647654
core --&gt; dgram
@@ -653,12 +660,14 @@ <h2 id="imports-graph">Imports graph</h2>
653660
dgram --&gt; utils
654661
vitestutils --&gt; utils
655662
vitestutils --&gt; types
663+
testutils --&gt; utils
664+
testutils --&gt; types
656665
</code></pre>
657666
<p>The graph is acyclic and layered:</p>
658667
<ul>
659668
<li><strong>Foundation (no internal dependencies):</strong> <code>@matterbridge/types</code>, <code>@matterbridge/utils</code>.</li>
660669
<li><strong>Networking &amp; workers:</strong> <code>@matterbridge/dgram</code> (→ <code>utils</code>), <code>@matterbridge/thread</code> (→ <code>utils</code>, <code>types</code>).</li>
661-
<li><strong>Test helpers:</strong> <code>@matterbridge/jest-utils</code> and <code>@matterbridge/vitest-utils</code> (→ <code>utils</code>, <code>types</code>).</li>
670+
<li><strong>Test helpers:</strong> <code>@matterbridge/jest-utils</code>, <code>@matterbridge/vitest-utils</code> and <code>@matterbridge/test-utils</code> (→ <code>utils</code>, <code>types</code>).</li>
662671
<li><strong>Core:</strong> <code>@matterbridge/core</code> (→ <code>dgram</code>, <code>thread</code>, <code>utils</code>, <code>types</code>).</li>
663672
<li><strong>Top level:</strong> <code>matterbridge</code> declares all scoped packages as direct dependencies; <code>core</code> pulls in the rest transitively.</li>
664673
</ul>

package-lock.json

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"packages/types",
6161
"packages/jest-utils",
6262
"packages/vitest-utils",
63+
"packages/test-utils",
6364
"packages/utils",
6465
"packages/dgram",
6566
"packages/thread",
@@ -106,6 +107,26 @@
106107
"import": "./dist/vitest-utils/matter.js",
107108
"types": "./dist/vitest-utils/matter.d.ts"
108109
},
110+
"./test-utils": {
111+
"import": "./dist/test-utils/export.js",
112+
"types": "./dist/test-utils/export.d.ts"
113+
},
114+
"./test-utils/matter": {
115+
"import": "./dist/test-utils/matter/export.js",
116+
"types": "./dist/test-utils/matter/export.d.ts"
117+
},
118+
"./test-utils/jest": {
119+
"import": "./dist/test-utils/jest/export.js",
120+
"types": "./dist/test-utils/jest/export.d.ts"
121+
},
122+
"./test-utils/vitest": {
123+
"import": "./dist/test-utils/vitest/export.js",
124+
"types": "./dist/test-utils/vitest/export.d.ts"
125+
},
126+
"./test-utils/buntest": {
127+
"import": "./dist/test-utils/buntest/export.js",
128+
"types": "./dist/test-utils/buntest/export.d.ts"
129+
},
109130
"./logger": {
110131
"import": "./dist/logger/export.js",
111132
"types": "./dist/logger/export.d.ts"
@@ -401,6 +422,7 @@
401422
"@matterbridge/core": "3.10.7",
402423
"@matterbridge/dgram": "3.10.7",
403424
"@matterbridge/jest-utils": "3.10.7",
425+
"@matterbridge/test-utils": "3.10.7",
404426
"@matterbridge/thread": "3.10.7",
405427
"@matterbridge/types": "3.10.7",
406428
"@matterbridge/utils": "3.10.7",
@@ -409,6 +431,7 @@
409431
"node-persist-manager": "2.1.0"
410432
},
411433
"devDependencies": {
434+
"@matter/main": "0.17.9",
412435
"@types/bun": "1.4.0",
413436
"@types/node": "26.2.0",
414437
"@vitest/coverage-v8": "4.1.11",

packages/test-utils/package.json

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"name": "@matterbridge/test-utils",
3+
"version": "3.10.7",
4+
"description": "Matterbridge common and framework-specific test utilities",
5+
"author": "https://github.com/Luligu",
6+
"homepage": "https://matterbridge.io/",
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/Luligu/matterbridge.git",
10+
"directory": "packages/test-utils"
11+
},
12+
"bugs": {
13+
"url": "https://github.com/Luligu/matterbridge/issues"
14+
},
15+
"publishConfig": {
16+
"access": "public"
17+
},
18+
"keywords": [
19+
"matterbridge",
20+
"homebridge",
21+
"bridge",
22+
"plugin",
23+
"frontend",
24+
"matter.js",
25+
"matter-node.js",
26+
"matter",
27+
"matterprotocol",
28+
"iot",
29+
"smarthome",
30+
"connectedthings",
31+
"hap",
32+
"homekit",
33+
"siri",
34+
"google-home",
35+
"alexa",
36+
"homeassistant",
37+
"smartthings",
38+
"ewelink"
39+
],
40+
"license": "Apache-2.0",
41+
"funding": {
42+
"type": "buymeacoffee",
43+
"url": "https://www.buymeacoffee.com/luligugithub"
44+
},
45+
"type": "module",
46+
"main": "./dist/export.js",
47+
"types": "./dist/export.d.ts",
48+
"exports": {
49+
".": {
50+
"types": "./dist/export.d.ts",
51+
"import": "./dist/export.js"
52+
},
53+
"./matter": {
54+
"types": "./dist/matter/export.d.ts",
55+
"import": "./dist/matter/export.js"
56+
},
57+
"./jest": {
58+
"types": "./dist/jest/export.d.ts",
59+
"import": "./dist/jest/export.js"
60+
},
61+
"./vitest": {
62+
"types": "./dist/vitest/export.d.ts",
63+
"import": "./dist/vitest/export.js"
64+
},
65+
"./buntest": {
66+
"types": "./dist/buntest/export.d.ts",
67+
"import": "./dist/buntest/export.js"
68+
}
69+
},
70+
"engines": {
71+
"node": ">=20.19.0 <21.0.0 || >=22.13.0 <23.0.0 || >=24.0.0 <25.0.0 || >=26.0.0 <27.0.0"
72+
},
73+
"files": [
74+
"bin",
75+
"dist",
76+
"npm-shrinkwrap.json",
77+
"CHANGELOG.md"
78+
],
79+
"automator": {
80+
"node": true,
81+
"vitestTypes": true,
82+
"skipPackageJson": true,
83+
"skipTsconfig": true
84+
},
85+
"dependencies": {
86+
"@matter/main": "0.17.9",
87+
"@matterbridge/types": "3.10.7",
88+
"@matterbridge/utils": "3.10.7",
89+
"node-ansi-logger": "3.3.0"
90+
},
91+
"devDependencies": {
92+
"@types/bun": "1.4.0",
93+
"@types/jest": "30.0.0",
94+
"@types/node": "26.2.0",
95+
"vitest": "4.1.11"
96+
}
97+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* @file packages/test-utils/src/buntest.ts
3+
* @description Re-export the Bun test utility API used in the repo's buntest directory.
4+
* @author Luca Liguori
5+
* @created 2026-08-23
6+
* @version 1.0.0
7+
* @license Apache-2.0
8+
*
9+
* Copyright 2025, 2026, 2027 Luca Liguori.
10+
*
11+
* Licensed under the Apache License, Version 2.0 (the "License");
12+
* you may not use this file except in compliance with the License.
13+
* You may obtain a copy of the License at
14+
*
15+
* http://www.apache.org/licenses/LICENSE-2.0
16+
*
17+
* Unless required by applicable law or agreed to in writing, software
18+
* distributed under the License is distributed on an "AS IS" BASIS,
19+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+
* See the License for the specific language governing permissions and
21+
* limitations under the License.
22+
*/
23+
24+
/* oxlint-disable oxc/no-barrel-file */
25+
26+
export * from './matterTest.js';
27+
export * from './setupTest.js';

0 commit comments

Comments
 (0)