@telorun/assert 0.1.7 → 0.1.8

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.
@@ -11,6 +11,7 @@ interface ManifestAssertManifest {
11
11
  source: string;
12
12
  expect: {
13
13
  errors?: ExpectError[];
14
+ loadError?: string;
14
15
  };
15
16
  }
16
17
  export declare function create(manifest: ManifestAssertManifest, ctx: ResourceContext): Promise<Runnable>;
package/dist/manifest.js CHANGED
@@ -60,8 +60,28 @@ export async function create(manifest, ctx) {
60
60
  manifests = await loader.loadManifests(resolvedUrl);
61
61
  }
62
62
  catch (err) {
63
+ const errMsg = err instanceof Error ? err.message : String(err);
64
+ if (manifest.expect.loadError) {
65
+ if (errMsg.includes(manifest.expect.loadError)) {
66
+ ctx.stdout.write(bold(green(`Assert.Manifest.${name}: assertion passed`)) +
67
+ "\n " + green("✓") + " " + dim(`load error: ${errMsg}`) + "\n");
68
+ }
69
+ else {
70
+ ctx.stderr.write(bold(red(`Assert.Manifest.${name}: assertion failed`)) +
71
+ "\n " + red("✗") + ` expected load error containing "${manifest.expect.loadError}"` +
72
+ "\n " + dim(`actual: ${errMsg}`) + "\n");
73
+ ctx.requestExit(1);
74
+ }
75
+ return;
76
+ }
63
77
  ctx.stderr.write(bold(red(`Assert.Manifest.${name}: failed to load "${manifest.source}"`)) +
64
- "\n " + (err instanceof Error ? err.message : String(err)) + "\n");
78
+ "\n " + errMsg + "\n");
79
+ ctx.requestExit(1);
80
+ return;
81
+ }
82
+ if (manifest.expect.loadError) {
83
+ ctx.stderr.write(bold(red(`Assert.Manifest.${name}: assertion failed`)) +
84
+ "\n " + red("✗") + ` expected load error containing "${manifest.expect.loadError}" but manifest loaded successfully\n`);
65
85
  ctx.requestExit(1);
66
86
  return;
67
87
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telorun/assert",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Telo Assert module - Assertion resource kinds for Telo manifests.",
5
5
  "keywords": [
6
6
  "telo",
@@ -31,7 +31,7 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@sinclair/typebox": "^0.34.48",
34
- "@telorun/analyzer": "0.1.3",
34
+ "@telorun/analyzer": "0.1.4",
35
35
  "@telorun/sdk": "0.2.8"
36
36
  },
37
37
  "devDependencies": {
package/src/manifest.ts CHANGED
@@ -13,6 +13,7 @@ interface ManifestAssertManifest {
13
13
  source: string;
14
14
  expect: {
15
15
  errors?: ExpectError[];
16
+ loadError?: string;
16
17
  };
17
18
  }
18
19
 
@@ -84,9 +85,35 @@ export async function create(
84
85
  try {
85
86
  manifests = await loader.loadManifests(resolvedUrl);
86
87
  } catch (err) {
88
+ const errMsg = err instanceof Error ? err.message : String(err);
89
+ if (manifest.expect.loadError) {
90
+ if (errMsg.includes(manifest.expect.loadError)) {
91
+ ctx.stdout.write(
92
+ bold(green(`Assert.Manifest.${name}: assertion passed`)) +
93
+ "\n " + green("✓") + " " + dim(`load error: ${errMsg}`) + "\n",
94
+ );
95
+ } else {
96
+ ctx.stderr.write(
97
+ bold(red(`Assert.Manifest.${name}: assertion failed`)) +
98
+ "\n " + red("✗") + ` expected load error containing "${manifest.expect.loadError}"` +
99
+ "\n " + dim(`actual: ${errMsg}`) + "\n",
100
+ );
101
+ ctx.requestExit(1);
102
+ }
103
+ return;
104
+ }
87
105
  ctx.stderr.write(
88
106
  bold(red(`Assert.Manifest.${name}: failed to load "${manifest.source}"`)) +
89
- "\n " + (err instanceof Error ? err.message : String(err)) + "\n",
107
+ "\n " + errMsg + "\n",
108
+ );
109
+ ctx.requestExit(1);
110
+ return;
111
+ }
112
+
113
+ if (manifest.expect.loadError) {
114
+ ctx.stderr.write(
115
+ bold(red(`Assert.Manifest.${name}: assertion failed`)) +
116
+ "\n " + red("✗") + ` expected load error containing "${manifest.expect.loadError}" but manifest loaded successfully\n`,
90
117
  );
91
118
  ctx.requestExit(1);
92
119
  return;