@youssoufcherif/signals-testing 0.0.1

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 Youssouf Cherif Hamed
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 ADDED
@@ -0,0 +1,34 @@
1
+ # @youssoufcherif/signals-testing
2
+
3
+ > ⚠️ **Pre-alpha (`0.0.x`)** — built in the open, APIs change without notice.
4
+ > Not yet supported for use outside the author's projects. See the
5
+ > [repo README](https://github.com/yhcherif/signals#readme).
6
+
7
+ Assertion helpers for testing code instrumented with
8
+ [Signals](https://github.com/yhcherif/signals), built on the in-memory
9
+ provider — no mocking library, ever. Re-exports `createMemorySignals` so a
10
+ test file needs a single import.
11
+
12
+ ```bash
13
+ pnpm add -D @youssoufcherif/signals-testing
14
+ ```
15
+
16
+ ```ts
17
+ import {
18
+ createMemorySignals,
19
+ expectLogMessage,
20
+ expectMetric,
21
+ expectSpan,
22
+ expectSpanEnded,
23
+ } from '@youssoufcherif/signals-testing';
24
+
25
+ const signals = createMemorySignals();
26
+ await processCheckout(signals, order); // your code, Signals injected
27
+
28
+ const span = expectSpan(signals, 'checkout.process');
29
+ expectSpanEnded(signals, 'checkout.process');
30
+ expectLogMessage(signals, 'processing checkout');
31
+ expectMetric(signals, 'payment.attempts');
32
+ ```
33
+
34
+ MIT © Youssouf Cherif Hamed
@@ -0,0 +1,11 @@
1
+ import type { MemorySignals, RecordedSpan } from '@youssoufcherif/signals-memory';
2
+ /**
3
+ * Finds a recorded span by name, or throws with a helpful message listing
4
+ * what was actually recorded. Plain function, not a custom Vitest matcher
5
+ * — keeps this package usable from any test runner, not just Vitest.
6
+ */
7
+ export declare function expectSpan(signals: MemorySignals, name: string): RecordedSpan;
8
+ export declare function expectSpanEnded(signals: MemorySignals, name: string): void;
9
+ export declare function expectLogMessage(signals: MemorySignals, message: string): void;
10
+ export declare function expectMetric(signals: MemorySignals, name: string): void;
11
+ //# sourceMappingURL=assertions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertions.d.ts","sourceRoot":"","sources":["../src/assertions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAElF;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAS7E;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAK1E;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAQ9E;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAQvE"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Finds a recorded span by name, or throws with a helpful message listing
3
+ * what was actually recorded. Plain function, not a custom Vitest matcher
4
+ * — keeps this package usable from any test runner, not just Vitest.
5
+ */
6
+ export function expectSpan(signals, name) {
7
+ const span = signals.getSpans().find((s) => s.name === name);
8
+ if (!span) {
9
+ const recordedNames = signals.getSpans().map((s) => s.name);
10
+ throw new Error(`Expected a span named "${name}" but none was recorded. Recorded spans: [${recordedNames.join(', ')}]`);
11
+ }
12
+ return span;
13
+ }
14
+ export function expectSpanEnded(signals, name) {
15
+ const span = expectSpan(signals, name);
16
+ if (!span.ended) {
17
+ throw new Error(`Expected span "${name}" to have ended, but it is still open.`);
18
+ }
19
+ }
20
+ export function expectLogMessage(signals, message) {
21
+ const found = signals.getLogs().some((log) => log.message === message);
22
+ if (!found) {
23
+ const recordedMessages = signals.getLogs().map((log) => log.message);
24
+ throw new Error(`Expected a log with message "${message}" but none was recorded. Recorded messages: [${recordedMessages.join(', ')}]`);
25
+ }
26
+ }
27
+ export function expectMetric(signals, name) {
28
+ const found = signals.getMetrics().some((metric) => metric.name === name);
29
+ if (!found) {
30
+ const recordedNames = signals.getMetrics().map((metric) => metric.name);
31
+ throw new Error(`Expected a metric named "${name}" but none was recorded. Recorded metrics: [${recordedNames.join(', ')}]`);
32
+ }
33
+ }
34
+ //# sourceMappingURL=assertions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertions.js","sourceRoot":"","sources":["../src/assertions.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,OAAsB,EAAE,IAAY;IAC7D,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAC7D,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,aAAa,GAAG,OAAO,CAAC,QAAQ,EAAE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EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACxE,MAAM,IAAI,KAAK,CACb,4BAA4B,IAAI,+CAA+C,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAC3G,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { expectLogMessage, expectMetric, expectSpan, expectSpanEnded } from './assertions.js';
2
+ export { createMemorySignals } from '@youssoufcherif/signals-memory';
3
+ export type { MemorySignals, RecordedLog, RecordedMetric, RecordedSpan, } from '@youssoufcherif/signals-memory';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC9F,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,YAAY,EACV,aAAa,EACb,WAAW,EACX,cAAc,EACd,YAAY,GACb,MAAM,gCAAgC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { expectLogMessage, expectMetric, expectSpan, expectSpanEnded } from './assertions.js';
2
+ export { createMemorySignals } from '@youssoufcherif/signals-memory';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC9F,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@youssoufcherif/signals-testing",
3
+ "version": "0.0.1",
4
+ "description": "Assertion helpers for testing code instrumented with Signals.",
5
+ "license": "MIT",
6
+ "author": "Youssouf Cherif Hamed <youssouf.cherif.hamed@gmail.com>",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/yhcherif/signals.git",
10
+ "directory": "packages/testing"
11
+ },
12
+ "homepage": "https://github.com/yhcherif/signals/tree/main/packages/testing#readme",
13
+ "bugs": "https://github.com/yhcherif/signals/issues",
14
+ "keywords": [
15
+ "telemetry",
16
+ "observability",
17
+ "signals",
18
+ "testing",
19
+ "assertions",
20
+ "vitest"
21
+ ],
22
+ "type": "module",
23
+ "sideEffects": false,
24
+ "engines": {
25
+ "node": ">=20"
26
+ },
27
+ "main": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js"
33
+ }
34
+ },
35
+ "files": [
36
+ "dist",
37
+ "LICENSE"
38
+ ],
39
+ "publishConfig": {
40
+ "access": "public",
41
+ "provenance": true
42
+ },
43
+ "dependencies": {
44
+ "@youssoufcherif/signals-core": "0.0.1",
45
+ "@youssoufcherif/signals-memory": "0.0.1"
46
+ },
47
+ "devDependencies": {
48
+ "typescript": "^5.6.0",
49
+ "vitest": "^2.1.0"
50
+ },
51
+ "scripts": {
52
+ "build": "tsc -p tsconfig.json",
53
+ "test": "vitest run"
54
+ }
55
+ }