risei 1.0.2 → 1.0.4
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 +35 -33
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -264,7 +264,7 @@ export TargetClassTests extends ATestSource {
|
|
|
264
264
|
- When necessary, you can provide a function to use in place of the real code, in `.as`.
|
|
265
265
|
|
|
266
266
|
|
|
267
|
-
- This example uses
|
|
267
|
+
- This example uses all three syntax options:
|
|
268
268
|
|
|
269
269
|
<div style="padding-left: 1.5rem;">
|
|
270
270
|
|
|
@@ -282,9 +282,22 @@ export TargetClassTests extends ATestSource {
|
|
|
282
282
|
|
|
283
283
|
</div>
|
|
284
284
|
|
|
285
|
-
-
|
|
286
|
-
|
|
287
|
-
-
|
|
285
|
+
- You can spoof methods nested inside of other objects using `.` syntax in the `.of` property:
|
|
286
|
+
|
|
287
|
+
<div style="padding-left: 1.5rem;">
|
|
288
|
+
|
|
289
|
+
```javascript
|
|
290
|
+
plus: [
|
|
291
|
+
{ on: SimpleObject, of: "getText", as: "Text" },
|
|
292
|
+
{ on: DeepObject, of: "root.branch.leaf.getOptimum", as: 100 }
|
|
293
|
+
]
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
</div>
|
|
297
|
+
|
|
298
|
+
- Types whose members are being spoofed (like `ArraySource` or `SimpleObject` in the examples) have to be imported normally.
|
|
299
|
+
- The properties in the spoof definitions within `.plus` don't collapse forward within the array, but must be repeated for each one.
|
|
300
|
+
- You can spoof methods of objects provided in a test's `.with` and `.in` as well, although you usually don't need to.
|
|
288
301
|
- Properties of spoof objects also have long names (covered later).
|
|
289
302
|
|
|
290
303
|
<details>
|
|
@@ -293,7 +306,7 @@ export TargetClassTests extends ATestSource {
|
|
|
293
306
|
</summary>
|
|
294
307
|
<br>
|
|
295
308
|
|
|
296
|
-
|
|
309
|
+
- You can spoof many methods on a class at the same time with an array of partial spoof objects for the `.as` property:
|
|
297
310
|
|
|
298
311
|
<div style="padding-left: 1.5rem;">
|
|
299
312
|
|
|
@@ -309,21 +322,9 @@ export TargetClassTests extends ATestSource {
|
|
|
309
322
|
|
|
310
323
|
</div>
|
|
311
324
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
- You can spoof methods and properties nested inside of other objects using `.` syntax in the `.of` property:
|
|
316
|
-
|
|
317
|
-
<div style="padding-left: 1.5rem;">
|
|
318
|
-
|
|
319
|
-
```javascript
|
|
320
|
-
plus: [
|
|
321
|
-
{ on: SimpleObject, of: "getText", as: "Text" },
|
|
322
|
-
{ on: DeepObject, of: "root.branch.leaf.getOptimum", as: 100 }
|
|
323
|
-
]
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
</div>
|
|
325
|
+
- You can use this syntax, or list multiple full `.on`-`.as`-`.of` objects for a class in `.plus`, with the same effect either way.
|
|
326
|
+
- Nested partial spoof definitions in `.as: [ ... ]` never contain `.on`, and must contain at least `.of`.
|
|
327
|
+
- As in other spoof definitions, `.as` can be omitted in these nested partial spoof objects, with the same effect.
|
|
327
328
|
|
|
328
329
|
</details>
|
|
329
330
|
|
|
@@ -382,7 +383,7 @@ node ./node_modules/risei/index.js
|
|
|
382
383
|
|
|
383
384
|
</div>
|
|
384
385
|
|
|
385
|
-
- You can define your test
|
|
386
|
+
- You can define your test scripting to include the RiseiJs tests alongside other tests if you wish to mix framework usages, which may be appropriate for some scenarios:
|
|
386
387
|
|
|
387
388
|
<div style="padding-left: 1.5rem;">
|
|
388
389
|
|
|
@@ -463,7 +464,7 @@ To test a static method, you add an `.and` property to a test, with the value `"
|
|
|
463
464
|
|
|
464
465
|
### Testing object properties and other non-`return` results
|
|
465
466
|
|
|
466
|
-
To test a value that isn't the exercised code's return value, you add a `.from` property to
|
|
467
|
+
To test a value that isn't the exercised code's return value, you use `.out` normally, and you add a `.from` property to your test, which can be one of two things:
|
|
467
468
|
|
|
468
469
|
<div style="padding-left: 1.5rem">
|
|
469
470
|
|
|
@@ -472,10 +473,11 @@ To test a value that isn't the exercised code's return value, you add a `.from`
|
|
|
472
473
|
| Property name as string | Retrieves the actual from the named property on the test's target class |
|
|
473
474
|
| Specialized function | Retrieves the actual from either its `target` or `test` parameter |
|
|
474
475
|
|
|
476
|
+
</div>
|
|
477
|
+
|
|
475
478
|
- Getting properties, mutated args, and other non-return values is known as _retrieving_.
|
|
476
479
|
- Retrieving definitions collapse forward across tests unless replaced with new definitions, or erased by setting `.from` to an empty array `[ ]`.
|
|
477
480
|
|
|
478
|
-
</div>
|
|
479
481
|
|
|
480
482
|
<details>
|
|
481
483
|
<summary>
|
|
@@ -518,7 +520,7 @@ When the contents of `.from` are a function, these are the two parameters:
|
|
|
518
520
|
- You can write a function for `.from` that uses `test.on` to get the values of static properties, in conjunction with `and: "static"` in the encompassing test.
|
|
519
521
|
|
|
520
522
|
|
|
521
|
-
- Another usage of `.from` function is to look at an input to see if it was changed as expected:
|
|
523
|
+
- Another usage of a `.from` function is to look at an input to see if it was changed as expected:
|
|
522
524
|
|
|
523
525
|
<div style="padding-left: 1.5rem">
|
|
524
526
|
|
|
@@ -603,7 +605,7 @@ The following are not supported at present:
|
|
|
603
605
|
- Standalone functions and other functionality not built into classes, AKA _loose code_
|
|
604
606
|
- CJS syntax using `require()`
|
|
605
607
|
- Spoofing mixes of properties and methods, such as `something.method.property.method`
|
|
606
|
-
|
|
608
|
+
- Debugging model code during tests.
|
|
607
609
|
|
|
608
610
|
## Troubleshooting
|
|
609
611
|
|
|
@@ -611,21 +613,21 @@ Most problems with using RiseiJs are minor mistakes in syntax, or omissions in t
|
|
|
611
613
|
|
|
612
614
|
| Error text | Probable cause / fix |
|
|
613
615
|
|---------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|
|
|
614
|
-
| `"Test loading failed for... SyntaxError: Unexpected token ':'"` |
|
|
615
|
-
| `"Test loading failed for... SyntaxError: Unexpected token '.'"` |
|
|
616
|
-
| Other `... Unexpected token ...` errors |
|
|
617
|
-
| Unexpected actual values, or unexpected passes / fails in test runs | Spoofs, retrievals, or
|
|
616
|
+
| `"Test loading failed for... SyntaxError: Unexpected token ':'"` | Missing comma in your tests in the named file |
|
|
617
|
+
| `"Test loading failed for... SyntaxError: Unexpected token '.'"` | Using `this.tests = []` instead of `tests = []` in the file named |
|
|
618
|
+
| Other `... Unexpected token ...` errors | Some other syntax error in the file named, most likely a missing or extra delimiter |
|
|
619
|
+
| Unexpected actual values, or unexpected passes / fails in test runs | Spoofs, retrievals, or special conditions from previous tests not replaced or reset with `[ ]`
|
|
618
620
|
|
|
619
|
-
|
|
621
|
+
When something is wrong in one test file, other test files still usually load and run, so a good sign that there's a problem is a sudden decrease in the number of run tests reported.
|
|
620
622
|
|
|
621
623
|
|
|
622
|
-
## Who
|
|
624
|
+
## Who makes RiseiJs
|
|
623
625
|
|
|
624
|
-
RiseiJs is
|
|
626
|
+
RiseiJs is written by myself, Ed Fallin. I'm a longtime software developer who likes to find better ways to do things.
|
|
625
627
|
|
|
626
628
|
If you find RiseiJs useful, consider spreading the word to other devs, making a donation, suggesting enhancements, or proposing sponsorships.
|
|
627
629
|
|
|
628
|
-
You can get in touch about
|
|
630
|
+
You can get in touch about RiseiJs at **riseijsmaker@gmail.com**.
|
|
629
631
|
|
|
630
632
|
|
|
631
633
|
## What the RiseiJs license is
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "risei",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "RiseiJs is the framework that allows you to write unit tests as collections of values in JavaScript objects, so it's easy and fast, and tests don't serve as a drag on redesigns.",
|
|
5
|
-
"keywords":[ "unit test", "test", "
|
|
5
|
+
"keywords": [ "unit test", "test", "unit testing", "testing", "easy", "fast", "values", "objects", "declarative" ],
|
|
6
6
|
"author": "Ed Fallin <riseijsmaker@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"type": "module",
|