@travetto/test 6.0.0-rc.2 → 6.0.0-rc.3

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/README.md CHANGED
@@ -122,6 +122,7 @@ The equivalences for all of the [assert](https://nodejs.org/api/assert.html) ope
122
122
  * `assert(a instanceof b)` as `assert.instanceOf(a, b)`
123
123
  * `assert(a.includes(b))` as `assert.ok(a.includes(b))`
124
124
  * `assert(/a/.test(b))` as `assert.ok(/a/.test(b))`
125
+
125
126
  In addition to the standard operations, there is support for throwing/rejecting errors (or the inverse). This is useful for testing error states or ensuring errors do not occur.
126
127
 
127
128
  ### Throws
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/test",
3
- "version": "6.0.0-rc.2",
3
+ "version": "6.0.0-rc.3",
4
4
  "description": "Declarative test framework",
5
5
  "keywords": [
6
6
  "unit-testing",
@@ -34,7 +34,7 @@
34
34
  "yaml": "^2.7.1"
35
35
  },
36
36
  "peerDependencies": {
37
- "@travetto/cli": "^6.0.0-rc.2",
37
+ "@travetto/cli": "^6.0.0-rc.3",
38
38
  "@travetto/transformer": "^6.0.0-rc.3"
39
39
  },
40
40
  "peerDependenciesMeta": {
@@ -156,10 +156,11 @@ export class AssertCheck {
156
156
  });
157
157
  }
158
158
  } else if (typeof shouldThrow === 'function') {
159
+ const target = shouldThrow.name ? `("${shouldThrow.name}")` : '';
159
160
  try {
160
161
  const res = shouldThrow(err);
161
162
  if (res === false) {
162
- return new assert.AssertionError({ message: `Checking "${shouldThrow.name}" indicated an invalid error`, actual: err });
163
+ return new assert.AssertionError({ message: `Checking function ${target} indicated an invalid error`, actual: err });
163
164
  } else if (typeof res === 'string') {
164
165
  return new assert.AssertionError({ message: res, actual: err });
165
166
  }
@@ -167,7 +168,7 @@ export class AssertCheck {
167
168
  if (checkErr instanceof assert.AssertionError) {
168
169
  return checkErr;
169
170
  } else {
170
- return new assert.AssertionError({ message: `Checking "${shouldThrow.name}" threw an error`, actual: checkErr });
171
+ return new assert.AssertionError({ message: `Checking function ${target} threw an error`, actual: checkErr });
171
172
  }
172
173
  }
173
174
  }