xunit.ts 0.12.0 → 1.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.
Files changed (185) hide show
  1. package/.editorconfig +24 -0
  2. package/README.md +27 -269
  3. package/SECURITY.md +11 -0
  4. package/cli.ts +2 -1
  5. package/dist/cli.js +2 -1
  6. package/dist/cli.js.map +1 -1
  7. package/dist/src/Assertions/Contains.d.ts +16 -1
  8. package/dist/src/Assertions/Contains.d.ts.map +1 -1
  9. package/dist/src/Assertions/Contains.js +15 -0
  10. package/dist/src/Assertions/Contains.js.map +1 -1
  11. package/dist/src/Assertions/Count.d.ts +16 -1
  12. package/dist/src/Assertions/Count.d.ts.map +1 -1
  13. package/dist/src/Assertions/Count.js +15 -0
  14. package/dist/src/Assertions/Count.js.map +1 -1
  15. package/dist/src/Assertions/Defined.d.ts +15 -1
  16. package/dist/src/Assertions/Defined.d.ts.map +1 -1
  17. package/dist/src/Assertions/Defined.js +17 -3
  18. package/dist/src/Assertions/Defined.js.map +1 -1
  19. package/dist/src/Assertions/DoesNotContain.d.ts +17 -0
  20. package/dist/src/Assertions/DoesNotContain.d.ts.map +1 -0
  21. package/dist/src/Assertions/DoesNotContain.js +30 -0
  22. package/dist/src/Assertions/DoesNotContain.js.map +1 -0
  23. package/dist/src/Assertions/DoesNotThrow.d.ts +14 -0
  24. package/dist/src/Assertions/DoesNotThrow.d.ts.map +1 -1
  25. package/dist/src/Assertions/DoesNotThrow.js +15 -0
  26. package/dist/src/Assertions/DoesNotThrow.js.map +1 -1
  27. package/dist/src/Assertions/Empty.d.ts +15 -1
  28. package/dist/src/Assertions/Empty.d.ts.map +1 -1
  29. package/dist/src/Assertions/Empty.js +17 -3
  30. package/dist/src/Assertions/Empty.js.map +1 -1
  31. package/dist/src/Assertions/Equal.d.ts +15 -0
  32. package/dist/src/Assertions/Equal.d.ts.map +1 -1
  33. package/dist/src/Assertions/Equal.js +16 -1
  34. package/dist/src/Assertions/Equal.js.map +1 -1
  35. package/dist/src/Assertions/False.d.ts +15 -1
  36. package/dist/src/Assertions/False.d.ts.map +1 -1
  37. package/dist/src/Assertions/False.js +17 -3
  38. package/dist/src/Assertions/False.js.map +1 -1
  39. package/dist/src/Assertions/InstanceOf.d.ts +16 -1
  40. package/dist/src/Assertions/InstanceOf.d.ts.map +1 -1
  41. package/dist/src/Assertions/InstanceOf.js +19 -4
  42. package/dist/src/Assertions/InstanceOf.js.map +1 -1
  43. package/dist/src/Assertions/NotEmpty.d.ts +15 -1
  44. package/dist/src/Assertions/NotEmpty.d.ts.map +1 -1
  45. package/dist/src/Assertions/NotEmpty.js +17 -3
  46. package/dist/src/Assertions/NotEmpty.js.map +1 -1
  47. package/dist/src/Assertions/NotEqual.d.ts +15 -0
  48. package/dist/src/Assertions/NotEqual.d.ts.map +1 -1
  49. package/dist/src/Assertions/NotEqual.js +20 -1
  50. package/dist/src/Assertions/NotEqual.js.map +1 -1
  51. package/dist/src/Assertions/NotNull.d.ts +15 -1
  52. package/dist/src/Assertions/NotNull.d.ts.map +1 -1
  53. package/dist/src/Assertions/NotNull.js +17 -3
  54. package/dist/src/Assertions/NotNull.js.map +1 -1
  55. package/dist/src/Assertions/Null.d.ts +15 -1
  56. package/dist/src/Assertions/Null.d.ts.map +1 -1
  57. package/dist/src/Assertions/Null.js +17 -3
  58. package/dist/src/Assertions/Null.js.map +1 -1
  59. package/dist/src/Assertions/StringContains.d.ts +15 -0
  60. package/dist/src/Assertions/StringContains.d.ts.map +1 -1
  61. package/dist/src/Assertions/StringContains.js +16 -1
  62. package/dist/src/Assertions/StringContains.js.map +1 -1
  63. package/dist/src/Assertions/StringDoesNotContain.d.ts +17 -0
  64. package/dist/src/Assertions/StringDoesNotContain.d.ts.map +1 -0
  65. package/dist/src/Assertions/StringDoesNotContain.js +30 -0
  66. package/dist/src/Assertions/StringDoesNotContain.js.map +1 -0
  67. package/dist/src/Assertions/StringDoesNotEndWith.d.ts +17 -0
  68. package/dist/src/Assertions/StringDoesNotEndWith.d.ts.map +1 -0
  69. package/dist/src/Assertions/StringDoesNotEndWith.js +32 -0
  70. package/dist/src/Assertions/StringDoesNotEndWith.js.map +1 -0
  71. package/dist/src/Assertions/StringDoesNotStartWith.d.ts +17 -0
  72. package/dist/src/Assertions/StringDoesNotStartWith.d.ts.map +1 -0
  73. package/dist/src/Assertions/StringDoesNotStartWith.js +30 -0
  74. package/dist/src/Assertions/StringDoesNotStartWith.js.map +1 -0
  75. package/dist/src/Assertions/StringEndsWith.d.ts +15 -0
  76. package/dist/src/Assertions/StringEndsWith.d.ts.map +1 -1
  77. package/dist/src/Assertions/StringEndsWith.js +18 -1
  78. package/dist/src/Assertions/StringEndsWith.js.map +1 -1
  79. package/dist/src/Assertions/StringStartsWith.d.ts +15 -0
  80. package/dist/src/Assertions/StringStartsWith.d.ts.map +1 -1
  81. package/dist/src/Assertions/StringStartsWith.js +15 -0
  82. package/dist/src/Assertions/StringStartsWith.js.map +1 -1
  83. package/dist/src/Assertions/Throws.d.ts +14 -0
  84. package/dist/src/Assertions/Throws.d.ts.map +1 -1
  85. package/dist/src/Assertions/Throws.js +14 -0
  86. package/dist/src/Assertions/Throws.js.map +1 -1
  87. package/dist/src/Assertions/True.d.ts +15 -1
  88. package/dist/src/Assertions/True.d.ts.map +1 -1
  89. package/dist/src/Assertions/True.js +17 -3
  90. package/dist/src/Assertions/True.js.map +1 -1
  91. package/dist/src/Assertions/Undefined.d.ts +15 -1
  92. package/dist/src/Assertions/Undefined.d.ts.map +1 -1
  93. package/dist/src/Assertions/Undefined.js +17 -3
  94. package/dist/src/Assertions/Undefined.js.map +1 -1
  95. package/dist/src/Assertions/index.d.ts +4 -4
  96. package/dist/src/Assertions/index.d.ts.map +1 -1
  97. package/dist/src/Assertions/index.js +8 -8
  98. package/dist/src/Assertions/index.js.map +1 -1
  99. package/dist/src/CLI.d.ts +4 -1
  100. package/dist/src/CLI.d.ts.map +1 -1
  101. package/dist/src/CLI.js +9 -7
  102. package/dist/src/CLI.js.map +1 -1
  103. package/dist/src/Factory.d.ts +3 -2
  104. package/dist/src/Factory.d.ts.map +1 -1
  105. package/dist/src/Factory.js +4 -4
  106. package/dist/src/Factory.js.map +1 -1
  107. package/dist/src/Framework/Test.d.ts +14 -0
  108. package/dist/src/Framework/Test.d.ts.map +1 -1
  109. package/dist/src/Framework/Test.js +14 -0
  110. package/dist/src/Framework/Test.js.map +1 -1
  111. package/dist/src/Framework/TestSuite.d.ts +13 -4
  112. package/dist/src/Framework/TestSuite.d.ts.map +1 -1
  113. package/dist/src/Framework/TestSuite.js +9 -0
  114. package/dist/src/Framework/TestSuite.js.map +1 -1
  115. package/dist/src/Reporters/JUnitReporter.js +1 -1
  116. package/dist/src/Reporters/JUnitReporter.js.map +1 -1
  117. package/dist/src/Reporters/SonarReporter.d.ts.map +1 -1
  118. package/dist/src/Reporters/SonarReporter.js +3 -2
  119. package/dist/src/Reporters/SonarReporter.js.map +1 -1
  120. package/dist/src/Runners/Runner.d.ts +1 -1
  121. package/dist/src/Runners/Runner.d.ts.map +1 -1
  122. package/dist/src/Runners/Runner.js.map +1 -1
  123. package/dist/src/Runners/TestRunner.d.ts +1 -1
  124. package/dist/src/Runners/TestRunner.d.ts.map +1 -1
  125. package/dist/src/Runners/TestRunner.js +6 -5
  126. package/dist/src/Runners/TestRunner.js.map +1 -1
  127. package/dist/src/Runners/TestSuiteRunner.d.ts +1 -1
  128. package/dist/src/Runners/TestSuiteRunner.d.ts.map +1 -1
  129. package/dist/src/Runners/TestSuiteRunner.js.map +1 -1
  130. package/icon.svg +83 -0
  131. package/logo.svg +154 -0
  132. package/package.json +15 -9
  133. package/sonar-project.properties +1 -1
  134. package/src/Assertions/Contains.ts +16 -1
  135. package/src/Assertions/Count.ts +16 -1
  136. package/src/Assertions/Defined.ts +17 -3
  137. package/src/Assertions/DoesNotContain.ts +28 -0
  138. package/src/Assertions/DoesNotThrow.ts +15 -0
  139. package/src/Assertions/Empty.ts +17 -3
  140. package/src/Assertions/Equal.ts +15 -0
  141. package/src/Assertions/False.ts +17 -3
  142. package/src/Assertions/InstanceOf.ts +19 -4
  143. package/src/Assertions/NotEmpty.ts +17 -3
  144. package/src/Assertions/NotEqual.ts +17 -1
  145. package/src/Assertions/NotNull.ts +17 -3
  146. package/src/Assertions/Null.ts +17 -3
  147. package/src/Assertions/StringContains.ts +17 -2
  148. package/src/Assertions/StringDoesNotContain.ts +28 -0
  149. package/src/Assertions/StringDoesNotEndWith.ts +30 -0
  150. package/src/Assertions/StringDoesNotStartWith.ts +28 -0
  151. package/src/Assertions/StringEndsWith.ts +19 -2
  152. package/src/Assertions/StringStartsWith.ts +15 -0
  153. package/src/Assertions/Throws.ts +14 -0
  154. package/src/Assertions/True.ts +17 -3
  155. package/src/Assertions/Undefined.ts +17 -3
  156. package/src/Assertions/index.ts +4 -4
  157. package/src/CLI.ts +6 -5
  158. package/src/Factory.ts +6 -6
  159. package/src/Framework/Test.ts +14 -0
  160. package/src/Framework/TestSuite.ts +9 -0
  161. package/src/Reporters/SonarReporter.ts +2 -1
  162. package/src/Runners/Runner.ts +1 -1
  163. package/src/Runners/TestRunner.ts +7 -6
  164. package/src/Runners/TestSuiteRunner.ts +1 -1
  165. package/tsconfig.json +4 -2
  166. package/dist/src/Assertions/NotContains.d.ts +0 -2
  167. package/dist/src/Assertions/NotContains.d.ts.map +0 -1
  168. package/dist/src/Assertions/NotContains.js +0 -15
  169. package/dist/src/Assertions/NotContains.js.map +0 -1
  170. package/dist/src/Assertions/StringNotContains.d.ts +0 -2
  171. package/dist/src/Assertions/StringNotContains.d.ts.map +0 -1
  172. package/dist/src/Assertions/StringNotContains.js +0 -15
  173. package/dist/src/Assertions/StringNotContains.js.map +0 -1
  174. package/dist/src/Assertions/StringNotEndsWith.d.ts +0 -2
  175. package/dist/src/Assertions/StringNotEndsWith.d.ts.map +0 -1
  176. package/dist/src/Assertions/StringNotEndsWith.js +0 -15
  177. package/dist/src/Assertions/StringNotEndsWith.js.map +0 -1
  178. package/dist/src/Assertions/StringNotStartsWith.d.ts +0 -2
  179. package/dist/src/Assertions/StringNotStartsWith.d.ts.map +0 -1
  180. package/dist/src/Assertions/StringNotStartsWith.js +0 -15
  181. package/dist/src/Assertions/StringNotStartsWith.js.map +0 -1
  182. package/src/Assertions/NotContains.ts +0 -13
  183. package/src/Assertions/StringNotContains.ts +0 -13
  184. package/src/Assertions/StringNotEndsWith.ts +0 -13
  185. package/src/Assertions/StringNotStartsWith.ts +0 -13
package/.editorconfig ADDED
@@ -0,0 +1,24 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ indent_style = tab
6
+ trim_trailing_whitespace = true
7
+ insert_final_newline = false
8
+ max_line_length = off
9
+
10
+ [{*.yml,*.yaml}]
11
+ indent_style = space
12
+ indent_size = 2
13
+
14
+ [*.cs]
15
+ csharp_style_expression_bodied_methods = true
16
+ csharp_style_expression_bodied_constructors = true
17
+ csharp_style_expression_bodied_operators = true
18
+ csharp_style_expression_bodied_properties = true
19
+ csharp_style_expression_bodied_indexers = true
20
+ csharp_style_expression_bodied_accessors = true
21
+ csharp_style_expression_bodied_lambdas = true
22
+ csharp_style_expression_bodied_local_functions = true
23
+ csharp_style_namespace_declarations = file_scoped:warning
24
+ dotnet_diagnostic.S101.severity = suggestion
package/README.md CHANGED
@@ -1,7 +1,8 @@
1
+ ![xunit.ts logo](docs/assets/logo.png)
1
2
  # xunit.ts
2
3
  ### A TypeScript unit testing framework, following standard xUnit patterns
3
4
 
4
- [![npm version](https://badge.fury.io/js/xunit.ts.svg)](https://npmjs.com/package/xunit.ts)
5
+ [![npm version](https://img.shields.io/npm/v/xunit.ts?logo=npm&label=Install)](https://npmjs.com/package/xunit.ts)
5
6
  [![CI status](https://github.com/ecoAPM/xunit.ts/workflows/CI/badge.svg)](https://github.com/ecoAPM/xunit.ts/actions)
6
7
  [![Code Coverage](https://sonarcloud.io/api/project_badges/measure?project=ecoAPM_xunit.ts&metric=coverage)](https://sonarcloud.io/dashboard?id=ecoAPM_xunit.ts)
7
8
 
@@ -9,6 +10,10 @@
9
10
  [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=ecoAPM_xunit.ts&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=ecoAPM_xunit.ts)
10
11
  [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=ecoAPM_xunit.ts&metric=security_rating)](https://sonarcloud.io/dashboard?id=ecoAPM_xunit.ts)
11
12
 
13
+ ## Documentation
14
+
15
+ Detailed documentation is available at https://ecoAPM.github.io/xunit.ts
16
+
12
17
  ## Quick Start
13
18
 
14
19
  ### Requirements
@@ -20,7 +25,9 @@
20
25
  ### Installation
21
26
 
22
27
  `npm install --dev xunit.ts`
28
+
23
29
  or
30
+
24
31
  `yarn add --dev xunit.ts`
25
32
 
26
33
  ### Configure your test project
@@ -41,7 +48,7 @@ If you're using `rollup` or `vite`, you'll need to set `xunit.ts` as an `externa
41
48
 
42
49
  ### Create your first test
43
50
 
44
- `MyTestSuite.ts`
51
+ `MyTestSuite.ts`:
45
52
 
46
53
  ```ts
47
54
  import { Test, TestSuite } from 'xunit.ts';
@@ -59,12 +66,17 @@ export default class MyTestSuite extends TestSuite {
59
66
  You'll need to compile your TypeScript tests into JavaScript using `tsc` or a bundler such as `rollup`, `parcel`, `vite`, etc. (these are the supported ones, feel free to add your favorite to the `compiler-tests` directory!)
60
67
 
61
68
  Then run:
69
+
62
70
  `npm run xunit compiled_tests_dir`
71
+
63
72
  or
73
+
64
74
  `yarn xunit compiled_tests_dir`
75
+
65
76
  to run the tests.
66
77
 
67
78
  You can also run `xunit.ts` from a script in your `package.json`:
79
+
68
80
  ```json
69
81
  {
70
82
  "scripts": {
@@ -73,9 +85,9 @@ You can also run `xunit.ts` from a script in your `package.json`:
73
85
  }
74
86
  ```
75
87
 
76
- ### Output
88
+ ## Output
77
89
 
78
- #### Console
90
+ ### Console
79
91
 
80
92
  By default, `xunit.ts` will output test results to `stdout` so they can be captured by your terminal, or piped elsewhere:
81
93
 
@@ -91,284 +103,30 @@ My Test Suite
91
103
  ~/example $ _
92
104
  ```
93
105
 
94
- To prevent console output, pass the `--quiet` or `-q` flag.
95
-
96
- #### JUnit
97
-
98
- `xunit.ts` can produce a JUnit-formatted XML file, for consumption by other services, by passing the `--junit` or `-j` flag, followed by an optional filename.
99
-
100
- `yarn xunit dist/tests -j results.xml`
101
-
102
- If no filename is provided, results will be output to `junit.xml`.
103
-
104
- #### SonarQube / SonarCloud
105
-
106
- `xunit.ts` can produce a Sonar-formatted XML file, for consumption by SonarQube and/or SonarCloud, by passing the `--sonar` or `-s` flag, followed by an optional filename.
107
-
108
- `yarn xunit dist/tests -s results.xml`
109
-
110
- If no filename is provided, results will be output to `sonar.xml`.
111
-
112
- Note that this currently only works if built tests are output to the `dist` directory.
106
+ See the [full documentation](https://ecoAPM.github.io/xunit.ts) for a list of all available output options.
113
107
 
114
108
  ## Assertions
115
109
 
116
- `xunit.ts` has a built-in assertion library, or you can use your favorite third-party one: anything that uses Node.js' `AssertionError` is supported.
110
+ `xunit.ts` has a built-in assertion library, accessible via `this.assert...` from within a `TestSuite`, or you can use your favorite third-party one: anything that uses Node.js' `AssertionError` is supported.
117
111
 
118
112
  If you prefer, you can `import { Assert } from 'xunit.ts` and call e.g. `Assert.true(expression);` instead of `this.assert.true(expression);` for any included assertion.
119
113
 
120
- ### Basic
121
-
122
- #### True
123
-
124
- ```
125
- this.assert.true(expression);
126
- ```
127
-
128
- Passes if `expression` evaluates to `true`
129
-
130
- Fails if `expression` does not evaluate to `true`
131
-
132
- #### False
133
-
134
- ```
135
- this.assert.false(expression);
136
- ```
137
-
138
- Passes if `expression` evaluates to `false`
139
-
140
- Fails if `expression` does not evaluate to `false`
141
-
142
- ### Equality
143
-
144
- #### Equal
145
-
146
- (uses `lodash.equal()` under the hood for strongly-typed, deep equality checks)
147
-
148
- ```
149
- this.assert.equal(expected, actual);
150
- ```
151
-
152
- Passes if `actual` and `expected` evaluate to equal values
153
-
154
- Fails if `actual` and `expected` do not evaluate to equal values
155
-
156
- #### Not Equal
157
-
158
- ```
159
- this.assert.notEqual(expected, actual);
160
- ```
161
-
162
- Passes if `actual` and `expected` do not evaluate to equal values
163
-
164
- Fails if `actual` and `expected` evaluate to equal values
165
-
166
- ### Nullable
167
-
168
- #### Is Null
169
-
170
- ```
171
- this.assert.null(expression);
172
- ```
173
-
174
- Passes if `expression` evaluates to `null`
175
-
176
- Fails if `expression` does not evaluate to `null`
177
-
178
- #### Not Null
179
-
180
- ```
181
- this.assert.notNull(expression);
182
- ```
183
-
184
- Passes if `expression` does not evaluate to `null`
185
-
186
- Fails if `expression` evaluates to `null`
187
-
188
- #### Undefined
189
-
190
- ```
191
- this.assert.undefined(expression);
192
- ```
193
-
194
- Passes if `expression` evaluates to `undefined`
195
-
196
- Fails if `expression` does not evaluate to `undefined`
197
-
198
- #### Not Undefined
199
-
200
- ```
201
- this.assert.defined(expression);
202
- ```
203
-
204
- Passes if `expression` does not evaluate to `undefined`
205
-
206
- Fails if `expression` evaluates to `undefined`
207
-
208
- ### Arrays
209
-
210
- #### Contains
211
-
212
- ```
213
- this.assert.contains(needle, haystack);
214
- ```
215
-
216
- Passes if array `haystack` contains an element with a value of `needle`
217
-
218
- Fails if array `haystack` does not contain an element with a value of `needle`
219
-
220
- #### Does Not Contain
221
-
222
- ```
223
- this.assert.doesNotContain(needle, haystack);
224
- ```
225
-
226
- Passes if array `haystack` does not contain an element with a value of `needle`
227
-
228
- Fails if array `haystack` contains an element with a value of `needle`
229
-
230
- #### Is Empty
114
+ See the [full documentation](https://ecoAPM.github.io/xunit.ts) for a list of all available assertions.
231
115
 
232
- ```
233
- this.assert.empty(array);
234
- ```
235
-
236
- Passes if `array` contains zero elements
237
-
238
- Fails if `array` contains any elements
239
-
240
- #### Is Not Empty
241
-
242
- ```
243
- this.assert.notEmpty(array);
244
- ```
245
-
246
- Passes if `array` contains any elements
247
-
248
- Fails if `array` contains zero elements
249
-
250
- #### Count / Length
251
-
252
- ```
253
- this.assert.count(expected, array);
254
- ```
255
-
256
- Passes if `array` contains `expected` number of elements
257
-
258
- Fails if `array` does not contain `expected` number of elements
259
-
260
- ### Strings
261
-
262
- #### Contains
263
-
264
- ```
265
- this.assert.stringContains(needle, haystack);
266
- ```
267
-
268
- Passes if `needle` is a substring of `haystack`
269
-
270
- Fails if `needle` is not a substring of `haystack`
271
-
272
- #### Does Not Contain
273
-
274
- ```
275
- this.assert.stringDoesNotContain(needle, haystack);
276
- ```
277
-
278
- Passes if `needle` is not a substring of `haystack`
279
-
280
- Fails if `needle` is a substring of `haystack`
281
-
282
- #### Starts With
283
-
284
- ```
285
- this.assert.stringStartsWith(needle, haystack);
286
- ```
287
-
288
- Passes if the first characters of `haystack` match `needle`
289
-
290
- Fails if the first characters of `haystack` do not match `needle`
291
-
292
- #### Does Not Start With
293
-
294
- ```
295
- this.assert.stringDoesNotStartWith(needle, haystack);
296
- ```
297
-
298
- Passes if the first characters of `haystack` do not match `needle`
299
-
300
- Fails if the first characters of `haystack` match `needle`
301
-
302
- #### Ends With
303
-
304
- ```
305
- this.assert.stringEndsWith(needle, haystack);
306
- ```
307
-
308
- Passes if the final characters of `haystack` match `needle`
309
-
310
- Fails if the final characters of `haystack` do not match `needle`
311
-
312
- #### Does Not End With
313
-
314
- ```
315
- this.assert.stringDoesNotEndWith(needle, haystack);
316
- ```
317
-
318
- Passes if the final characters of `haystack` do not match `needle`
319
-
320
- Fails if the final characters of `haystack` match `needle`
321
-
322
- ### Exceptions
323
-
324
- #### Throws
325
-
326
- ```
327
- this.assert.throws(() => expression);
328
- ```
329
-
330
- Passes if `expression` throws an error/exception
331
-
332
- Fails if `expression` does not throw an error/exception
333
-
334
- #### Does Not Throw
335
-
336
- ```
337
- this.assert.doesNotThrow(() => expression);
338
- ```
339
-
340
- Passes if `expression` does not throw an error/exception
341
-
342
- Fails if `expression` throws an error/exception
343
-
344
- ### Reflection
345
-
346
- #### Is Instance Of
116
+ ## Contributing
347
117
 
348
- ```
349
- this.assert.instanceOf(type, object);
350
- ```
118
+ Please be sure to read and follow ecoAPM's [Contribution Guidelines](CONTRIBUTING.md) when submitting issues or pull requests.
351
119
 
352
- Passes if `object`'s type matches `type`
120
+ ### Building / Testing locally
353
121
 
354
- Fails if `object`'s type does not match `type`
122
+ 1. `npm install` or `yarn install` to download all dependencies
123
+ 2. `npm run build` or `yarn build` will compile `xunit.ts` and its tests to the `dist` directory
124
+ 3. `npm run test` or `yarn test` will run all unit tests in `dist/tests`
125
+ 4. `npm run build && npm run test` or `yarn build && yarn test` will build and run tests in a single step
355
126
 
356
127
  ### Missing an assertion?
357
128
 
358
129
  Create an issue or submit a pull request!
359
130
  1. Add a new function to `src/Assertions`
360
131
  2. Add tests for both the positive and negative cases in `tests/Assertions`
361
- 3. Add a field for the assertion to `src/Assertions/index.ts`
362
-
363
- See [Contributing](#Contributing) section below for details
364
-
365
- ## Contributing
366
-
367
- Please be sure to read and follow ecoAPM's [Contribution Guidelines](CONTRIBUTING.md) when submitting issues or pull requests.
368
-
369
- ### Building / Testing locally
370
-
371
- 1. `npm install` or `yarn install` to download all dependencies
372
- 1. `npm run build` or `yarn build` will compile `xunit.ts` and its tests to the `dist` directory
373
- 1. `npm run test` or `yarn test` will run all unit tests in `dist/tests`
374
- 1. `npm run build && npm run test` or `yarn build && yarn test` will build and run tests in a single step
132
+ 3. Add a field for the assertion to `src/Assertions/index.ts`
package/SECURITY.md ADDED
@@ -0,0 +1,11 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ Security updates are generally only applied to the newest release, and backported on an as-needed basis where appropriate.
6
+
7
+ ## Reporting a Vulnerability
8
+
9
+ Unless a vulnerability is deemed critical or exposes PII, please create an issue in this repository using the "Report a Bug" template.
10
+
11
+ For critical vulnerabilities, or those that expose PII, please email info@ecoAPM.com so that the issue can be fixed confidentially, prior to public disclosure.
package/cli.ts CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  import process from 'process';
4
4
  import CLI from './src/CLI';
5
+ import Factory from './src/Factory';
5
6
 
6
- new CLI(process)
7
+ new CLI(Factory.Runner, process)
7
8
  .run()
8
9
  .then(success => process.exit(success ? 0 : 1));
package/dist/cli.js CHANGED
@@ -6,7 +6,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const process_1 = __importDefault(require("process"));
8
8
  const CLI_1 = __importDefault(require("./src/CLI"));
9
- new CLI_1.default(process_1.default)
9
+ const Factory_1 = __importDefault(require("./src/Factory"));
10
+ new CLI_1.default(Factory_1.default.Runner, process_1.default)
10
11
  .run()
11
12
  .then(success => process_1.default.exit(success ? 0 : 1));
12
13
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../cli.ts"],"names":[],"mappings":";;;;;;AAEA,sDAA8B;AAC9B,oDAA4B;AAE5B,IAAI,aAAG,CAAC,iBAAO,CAAC;KACX,GAAG,EAAE;KACL,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,iBAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../cli.ts"],"names":[],"mappings":";;;;;;AAEA,sDAA8B;AAC9B,oDAA4B;AAC5B,4DAAoC;AAEpC,IAAI,aAAG,CAAC,iBAAO,CAAC,MAAM,EAAE,iBAAO,CAAC;KAC3B,GAAG,EAAE;KACL,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,iBAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
@@ -1,2 +1,17 @@
1
- export default function Contains<T>(needle: T, haystack: T[], message?: string): void;
1
+ /**
2
+ * Asserts that an array contains a given element
3
+ *
4
+ * @remarks
5
+ * Passes if array `haystack` contains an element with a value of `needle`
6
+ *
7
+ * Fails if array `haystack` does not contain an element with a value of `needle`
8
+ *
9
+ * @param needle the element to find
10
+ * @param haystack the array to search
11
+ * @param message (optional) message to display on failure
12
+ *
13
+ * @example
14
+ * this.assert.contains(needle, haystack);
15
+ */
16
+ export default function Contains<T>(needle: T, haystack: ReadonlyArray<T>, message?: string): void;
2
17
  //# sourceMappingURL=Contains.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Contains.d.ts","sourceRoot":"","sources":["../../../src/Assertions/Contains.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,QAU7E"}
1
+ {"version":3,"file":"Contains.d.ts","sourceRoot":"","sources":["../../../src/Assertions/Contains.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,QAU1F"}
@@ -1,6 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const assert_1 = require("assert");
4
+ /**
5
+ * Asserts that an array contains a given element
6
+ *
7
+ * @remarks
8
+ * Passes if array `haystack` contains an element with a value of `needle`
9
+ *
10
+ * Fails if array `haystack` does not contain an element with a value of `needle`
11
+ *
12
+ * @param needle the element to find
13
+ * @param haystack the array to search
14
+ * @param message (optional) message to display on failure
15
+ *
16
+ * @example
17
+ * this.assert.contains(needle, haystack);
18
+ */
4
19
  function Contains(needle, haystack, message) {
5
20
  if (haystack.includes(needle)) {
6
21
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"Contains.js","sourceRoot":"","sources":["../../../src/Assertions/Contains.ts"],"names":[],"mappings":";;AAAA,mCAAwC;AAExC,SAAwB,QAAQ,CAAI,MAAS,EAAE,QAAa,EAAE,OAAgB;IAC1E,IAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAC1B,OAAO;KACV;IAED,MAAM,IAAI,uBAAc,CAAC;QACrB,OAAO,EAAE,OAAO,IAAI,4EAA4E;QAChG,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,QAAQ;KACnB,CAAC,CAAC;AACP,CAAC;AAVD,2BAUC"}
1
+ {"version":3,"file":"Contains.js","sourceRoot":"","sources":["../../../src/Assertions/Contains.ts"],"names":[],"mappings":";;AAAA,mCAAwC;AAExC;;;;;;;;;;;;;;GAcG;AACH,SAAwB,QAAQ,CAAI,MAAS,EAAE,QAA0B,EAAE,OAAgB;IACvF,IAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAC1B,OAAO;KACV;IAED,MAAM,IAAI,uBAAc,CAAC;QACrB,OAAO,EAAE,OAAO,IAAI,4EAA4E;QAChG,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,QAAQ;KACnB,CAAC,CAAC;AACP,CAAC;AAVD,2BAUC"}
@@ -1,2 +1,17 @@
1
- export default function Count(expected: number, array: any[], message?: string): void;
1
+ /**
2
+ * Asserts that an array contains a certain number of elements
3
+ *
4
+ * @remarks
5
+ * Passes if `array` contains `expected` number of elements
6
+ *
7
+ * Fails if `array` does not contain `expected` number of elements
8
+ *
9
+ * @param expected the number of array elements expected
10
+ * @param array the array to check the length of
11
+ * @param message (optional) message to display on failure
12
+ *
13
+ * @example
14
+ * this.assert.count(expected, array);
15
+ */
16
+ export default function Count(expected: number, array: ReadonlyArray<any>, message?: string): void;
2
17
  //# sourceMappingURL=Count.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Count.d.ts","sourceRoot":"","sources":["../../../src/Assertions/Count.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,QAU7E"}
1
+ {"version":3,"file":"Count.d.ts","sourceRoot":"","sources":["../../../src/Assertions/Count.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,QAU1F"}
@@ -1,6 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const assert_1 = require("assert");
4
+ /**
5
+ * Asserts that an array contains a certain number of elements
6
+ *
7
+ * @remarks
8
+ * Passes if `array` contains `expected` number of elements
9
+ *
10
+ * Fails if `array` does not contain `expected` number of elements
11
+ *
12
+ * @param expected the number of array elements expected
13
+ * @param array the array to check the length of
14
+ * @param message (optional) message to display on failure
15
+ *
16
+ * @example
17
+ * this.assert.count(expected, array);
18
+ */
4
19
  function Count(expected, array, message) {
5
20
  if (array.length === expected) {
6
21
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"Count.js","sourceRoot":"","sources":["../../../src/Assertions/Count.ts"],"names":[],"mappings":";;AAAA,mCAAwC;AAExC,SAAwB,KAAK,CAAC,QAAgB,EAAE,KAAY,EAAE,OAAgB;IAC1E,IAAG,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE;QAC1B,OAAO;KACV;IAED,MAAM,IAAI,uBAAc,CAAC;QACrB,OAAO,EAAE,OAAO,IAAI,uBAAuB,QAAQ,4BAA4B,KAAK,CAAC,MAAM,WAAW;QACtG,QAAQ,EAAE,QAAQ;QAClB,MAAM,EAAE,KAAK,CAAC,MAAM;KACvB,CAAC,CAAC;AACP,CAAC;AAVD,wBAUC"}
1
+ {"version":3,"file":"Count.js","sourceRoot":"","sources":["../../../src/Assertions/Count.ts"],"names":[],"mappings":";;AAAA,mCAAwC;AAExC;;;;;;;;;;;;;;GAcG;AACH,SAAwB,KAAK,CAAC,QAAgB,EAAE,KAAyB,EAAE,OAAgB;IACvF,IAAG,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE;QAC1B,OAAO;KACV;IAED,MAAM,IAAI,uBAAc,CAAC;QACrB,OAAO,EAAE,OAAO,IAAI,uBAAuB,QAAQ,4BAA4B,KAAK,CAAC,MAAM,WAAW;QACtG,QAAQ,EAAE,QAAQ;QAClB,MAAM,EAAE,KAAK,CAAC,MAAM;KACvB,CAAC,CAAC;AACP,CAAC;AAVD,wBAUC"}
@@ -1,2 +1,16 @@
1
- export default function Defined(value: any, message?: string): void;
1
+ /**
2
+ * Asserts that a value is defined (any value other than `undefined`)
3
+ *
4
+ * @remarks
5
+ * Passes if `expression` does not evaluate to `undefined`
6
+ *
7
+ * Fails if `expression` evaluates to `undefined`
8
+ *
9
+ * @param expression the value to check
10
+ * @param message (optional) message to display on failure
11
+ *
12
+ * @example
13
+ * this.assert.defined(expression);
14
+ */
15
+ export default function Defined(expression: any, message?: string): void;
2
16
  //# sourceMappingURL=Defined.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Defined.d.ts","sourceRoot":"","sources":["../../../src/Assertions/Defined.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,QAU3D"}
1
+ {"version":3,"file":"Defined.d.ts","sourceRoot":"","sources":["../../../src/Assertions/Defined.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,UAAU,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,QAUhE"}
@@ -1,14 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const assert_1 = require("assert");
4
- function Defined(value, message) {
5
- if (value !== undefined) {
4
+ /**
5
+ * Asserts that a value is defined (any value other than `undefined`)
6
+ *
7
+ * @remarks
8
+ * Passes if `expression` does not evaluate to `undefined`
9
+ *
10
+ * Fails if `expression` evaluates to `undefined`
11
+ *
12
+ * @param expression the value to check
13
+ * @param message (optional) message to display on failure
14
+ *
15
+ * @example
16
+ * this.assert.defined(expression);
17
+ */
18
+ function Defined(expression, message) {
19
+ if (expression !== undefined) {
6
20
  return;
7
21
  }
8
22
  throw new assert_1.AssertionError({
9
23
  message: message || 'Expected expression to be defined, but expression is undefined',
10
24
  expected: '(not undefined expression)',
11
- actual: value
25
+ actual: expression
12
26
  });
13
27
  }
14
28
  exports.default = Defined;
@@ -1 +1 @@
1
- {"version":3,"file":"Defined.js","sourceRoot":"","sources":["../../../src/Assertions/Defined.ts"],"names":[],"mappings":";;AAAA,mCAAwC;AAExC,SAAwB,OAAO,CAAC,KAAU,EAAE,OAAgB;IACxD,IAAG,KAAK,KAAK,SAAS,EAAE;QACpB,OAAO;KACV;IAED,MAAM,IAAI,uBAAc,CAAC;QACrB,OAAO,EAAE,OAAO,IAAI,gEAAgE;QACpF,QAAQ,EAAE,4BAA4B;QACtC,MAAM,EAAE,KAAK;KAChB,CAAC,CAAC;AACP,CAAC;AAVD,0BAUC"}
1
+ {"version":3,"file":"Defined.js","sourceRoot":"","sources":["../../../src/Assertions/Defined.ts"],"names":[],"mappings":";;AAAA,mCAAwC;AAExC;;;;;;;;;;;;;GAaG;AACH,SAAwB,OAAO,CAAC,UAAe,EAAE,OAAgB;IAC7D,IAAG,UAAU,KAAK,SAAS,EAAE;QACzB,OAAO;KACV;IAED,MAAM,IAAI,uBAAc,CAAC;QACrB,OAAO,EAAE,OAAO,IAAI,gEAAgE;QACpF,QAAQ,EAAE,4BAA4B;QACtC,MAAM,EAAE,UAAU;KACrB,CAAC,CAAC;AACP,CAAC;AAVD,0BAUC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Asserts that an array does not contain a given element
3
+ *
4
+ * @remarks
5
+ * Passes if array `haystack` does not contain an element with a value of `needle`
6
+ *
7
+ * Fails if array `haystack` contains an element with a value of `needle`
8
+ *
9
+ * @param needle the element to find
10
+ * @param haystack the array to search
11
+ * @param message (optional) message to display on failure
12
+ *
13
+ * @example
14
+ * this.assert.doesNotContain(needle, haystack);
15
+ */
16
+ export default function DoesNotContain<T>(needle: T, haystack: ReadonlyArray<T>, message?: string): void;
17
+ //# sourceMappingURL=DoesNotContain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DoesNotContain.d.ts","sourceRoot":"","sources":["../../../src/Assertions/DoesNotContain.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,QAUhG"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const assert_1 = require("assert");
4
+ /**
5
+ * Asserts that an array does not contain a given element
6
+ *
7
+ * @remarks
8
+ * Passes if array `haystack` does not contain an element with a value of `needle`
9
+ *
10
+ * Fails if array `haystack` contains an element with a value of `needle`
11
+ *
12
+ * @param needle the element to find
13
+ * @param haystack the array to search
14
+ * @param message (optional) message to display on failure
15
+ *
16
+ * @example
17
+ * this.assert.doesNotContain(needle, haystack);
18
+ */
19
+ function DoesNotContain(needle, haystack, message) {
20
+ if (!haystack.includes(needle)) {
21
+ return;
22
+ }
23
+ throw new assert_1.AssertionError({
24
+ message: message || 'Expected array not containing expression, but array contained expression',
25
+ expected: needle,
26
+ actual: haystack
27
+ });
28
+ }
29
+ exports.default = DoesNotContain;
30
+ //# sourceMappingURL=DoesNotContain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DoesNotContain.js","sourceRoot":"","sources":["../../../src/Assertions/DoesNotContain.ts"],"names":[],"mappings":";;AAAA,mCAAwC;AAExC;;;;;;;;;;;;;;GAcG;AACH,SAAwB,cAAc,CAAI,MAAS,EAAE,QAA0B,EAAE,OAAgB;IAC7F,IAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAC3B,OAAO;KACV;IAED,MAAM,IAAI,uBAAc,CAAC;QACrB,OAAO,EAAE,OAAO,IAAI,0EAA0E;QAC9F,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,QAAQ;KACnB,CAAC,CAAC;AACP,CAAC;AAVD,iCAUC"}
@@ -1,2 +1,16 @@
1
+ /**
2
+ * Asserts that an expression does not throw an error/exception
3
+ *
4
+ * @remarks
5
+ * Passes if calling `expression` does not throw an error/exception
6
+ *
7
+ * Fails if calling `expression` throws an error/exception
8
+ *
9
+ * @param expression the expression to run
10
+ * @param message (optional) message to display on failure
11
+ *
12
+ * @example
13
+ * this.assert.doesNotThrow(() => expression);
14
+ */
1
15
  export default function DoesNotThrow(expression: () => any, message?: string): void;
2
16
  //# sourceMappingURL=DoesNotThrow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DoesNotThrow.d.ts","sourceRoot":"","sources":["../../../src/Assertions/DoesNotThrow.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,QAU3E"}
1
+ {"version":3,"file":"DoesNotThrow.d.ts","sourceRoot":"","sources":["../../../src/Assertions/DoesNotThrow.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,QAW3E"}