@irtio/testing 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) 2026 irtio contributors
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.
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The four matchers, as plain functions.
3
+ *
4
+ * They live apart from `matchers.ts` so the package's main entry can export them without importing
5
+ * Vitest: `@irtio/testing` has Vitest as an *optional* peer, and a bot or a plain Node script that
6
+ * only wants `testRoom` must not have to install a test runner. `@irtio/testing/matchers` is the
7
+ * entry that pulls Vitest in and calls `expect.extend`.
8
+ *
9
+ * Every failure message ends with the tail of the frame trace, because "the views disagree" is
10
+ * never the interesting part — *which frames went where* is.
11
+ */
12
+ /** The shape Vitest's `expect.extend` wants back. */
13
+ interface MatcherResult {
14
+ readonly pass: boolean;
15
+ message(): string;
16
+ }
17
+ /** How many trace entries a failure message carries. */
18
+ declare const TRACE_TAIL = 10;
19
+ /** No client can see a collection its role must not — in its view or in a frame it received. */
20
+ declare function toHaveNoVisibilityLeaks(received: unknown): MatcherResult;
21
+ /** Every client's view equals the authority projected to that client's role. */
22
+ declare function toHaveConverged(received: unknown): MatcherResult;
23
+ /** Some call to `rpcName` came back as an error `REPLY`. */
24
+ declare function toHaveRejected(received: unknown, rpcName: string): MatcherResult;
25
+ /** No client received more than `bytesPerTick` outbound bytes per room tick, on average. */
26
+ declare function toStayUnderBandwidth(received: unknown, bytesPerTick: number): MatcherResult;
27
+ /**
28
+ * The matcher table. Pass it to `expect.extend` yourself, or import `@irtio/testing/matchers`
29
+ * for the side effect.
30
+ */
31
+ declare const matchers: {
32
+ toHaveNoVisibilityLeaks: typeof toHaveNoVisibilityLeaks;
33
+ toHaveConverged: typeof toHaveConverged;
34
+ toHaveRejected: typeof toHaveRejected;
35
+ toStayUnderBandwidth: typeof toStayUnderBandwidth;
36
+ };
37
+
38
+ export { type MatcherResult as M, TRACE_TAIL as T, toHaveNoVisibilityLeaks as a, toHaveRejected as b, toStayUnderBandwidth as c, matchers as m, toHaveConverged as t };