risei 1.3.1 → 1.3.2
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 +22 -21
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -123,9 +123,9 @@ You can save a lot of time by putting repeated test properties into an object on
|
|
|
123
123
|
{ of: "countOf", for: "Returns the number present.", in: [ "b" ], out: 2 }
|
|
124
124
|
```
|
|
125
125
|
|
|
126
|
-
- This _collapsing forward_
|
|
126
|
+
- This _collapsing forward_ is reset when you change the class in `.on`, when you give the property a new value, or you erase it with an empty array `[ ]`.
|
|
127
127
|
|
|
128
|
-
-
|
|
128
|
+
- Tests are isolated in general, but if the code you're testing mutates its arguments, you have to state them in each test so the mutations aren't carried forward.
|
|
129
129
|
|
|
130
130
|
|
|
131
131
|
|
|
@@ -153,9 +153,9 @@ When your tests need certain results from code dependencies, just _spoof_ what y
|
|
|
153
153
|
in: [ "green" ], out: [ 7, 8, 9, 10, 10, 11, 12, { color: "green" } ] }
|
|
154
154
|
```
|
|
155
155
|
|
|
156
|
-
-
|
|
156
|
+
- It's just like _fakes_, _mocks_, or _test doubles_ in other test systems, but much easier to write and read.
|
|
157
157
|
|
|
158
|
-
-
|
|
158
|
+
- Spoofed code is fully isolated within tests, even though spoof definitions collapse forward across tests (and within `.plus`).
|
|
159
159
|
|
|
160
160
|
|
|
161
161
|
|
|
@@ -254,9 +254,9 @@ There's plenty more to learn about Risei and how it makes testing easy...
|
|
|
254
254
|
- Changing the tested class in `.on` wipes out all prior test properties, so the new class has a fresh start.
|
|
255
255
|
- Changing the tested method in `.of` wipes out only test properties related to methods, to preserve class values you usually want.
|
|
256
256
|
|
|
257
|
-
- Individual tests remain isolated, except for when args are
|
|
258
|
-
-
|
|
259
|
-
|
|
257
|
+
- Individual tests remain isolated, except for when args are mutated by the code under test.
|
|
258
|
+
- Restate args for each test when the code mutates them.
|
|
259
|
+
- This limitation is the result of limits on what can be copied reliably in JavaScript.
|
|
260
260
|
|
|
261
261
|
|
|
262
262
|
### Choosing test-only dependency inputs _AKA_ Spoofing
|
|
@@ -514,7 +514,7 @@ You set up the transpiler to output files to a directory with these settings:
|
|
|
514
514
|
|
|
515
515
|
### In test files:
|
|
516
516
|
|
|
517
|
-
All `import` statements have to point to the `outDir` path or subfolders there, using relative-path syntax:
|
|
517
|
+
All `import` statements have to point to the Javascript (`.js`) files in the `outDir` path or subfolders there, using relative-path syntax:
|
|
518
518
|
|
|
519
519
|
```javascript
|
|
520
520
|
import { TestedClass } from "../../dist/out-tsc/SubPath/TestedClass.js";
|
|
@@ -524,6 +524,7 @@ import { TestedClass } from "../../dist/out-tsc/SubPath/TestedClass.js";
|
|
|
524
524
|
|
|
525
525
|
|
|
526
526
|
|
|
527
|
+
|
|
527
528
|
## Limitations in Risei
|
|
528
529
|
|
|
529
530
|
The following are not supported at present:
|
|
@@ -544,15 +545,15 @@ Some of these are on the tentative future-development list. In the meanti
|
|
|
544
545
|
|
|
545
546
|
Most problems with using Risei are minor mistakes in syntax, or omissions in test definitions:
|
|
546
547
|
|
|
547
|
-
| Error condition or text | Probable cause
|
|
548
|
+
| Error condition or text | Probable cause |
|
|
548
549
|
|---------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
549
550
|
| Gold bar appears below the summary, and the number of tests run drops | A syntax error caused a test file not to load; error output in the gold bar explains why |
|
|
550
551
|
| `"Test loading failed for... SyntaxError: Unexpected token ':'"` | Missing comma in your tests in the named file |
|
|
551
552
|
| `"Test loading failed for... SyntaxError: Unexpected token '.'"` | Using `this.tests = []` instead of `tests = []` in the file named |
|
|
552
553
|
| Other `... Unexpected token ...` errors | Some other syntax error in the file named, most likely a missing or extra delimiter |
|
|
553
|
-
| Unexpected
|
|
554
|
-
| Unexpected actual values, or unexpected passes / fails in test runs |
|
|
555
|
-
|
|
554
|
+
| Unexpected extra, failing test/s | Partial test properties in a mid-list object have produced extra tests |
|
|
555
|
+
| Unexpected actual values, or unexpected passes / fails in test runs | Test properties from previous tests not replaced or reset with `[ ]` <br>— or —<br> Args mutated by tested code were not restated in following tests to isolate them |
|
|
556
|
+
|
|
556
557
|
|
|
557
558
|
|
|
558
559
|
|
|
@@ -560,22 +561,22 @@ Most problems with using Risei are minor mistakes in syntax, or omissions in tes
|
|
|
560
561
|
|
|
561
562
|
Two issues are known to exist:
|
|
562
563
|
|
|
563
|
-
-
|
|
564
|
-
- To
|
|
565
|
-
-
|
|
564
|
+
- When code mutates its args in test definitions, the mutated forms are used in subsequent tests unless those args are restated.
|
|
565
|
+
- To avoid this problem, just restate the args in each test of this code.
|
|
566
|
+
- The workaround for this — copying and initing objects to bypass mutation — requires too many assumptions to be reliable.
|
|
566
567
|
|
|
567
568
|
|
|
568
|
-
-
|
|
569
|
-
-
|
|
570
|
-
-
|
|
571
|
-
- To avoid this problem, include changed properties in full tests to run, or restate `.of` along with the changed properties.
|
|
572
|
-
- This situation is rarely an issue, but ways to optionally prevent it are being considered.
|
|
569
|
+
- When a few properties are changed in separate objects, they are treated as whole new tests, which usually fail because of their unintended mix of old and new properties.
|
|
570
|
+
- To avoid this problem, just change properties as part of whole new tests, or else restate `.of` along with the changed properties.
|
|
571
|
+
- Rs is actually working as intended when this happens, but ways to optionally prevent it are being considered.
|
|
573
572
|
|
|
574
573
|
|
|
575
574
|
|
|
576
575
|
## What's new in Risei
|
|
577
576
|
|
|
578
|
-
- Release **1.3.
|
|
577
|
+
- Release **1.3.2** (February, 2024) does not change the code at all, but improves this read-me, notably explaining the easiest way to deal with mutable args (which is just restating the args), and correcting a few mistakes.
|
|
578
|
+
|
|
579
|
+
- Release **1.3.1** (February, 2024) reverses some changes in 1.3.0 that were intended to fully isolate tests against mutable args, but which caused incomplete or inaccurate object contents in some cases. This sort of built-in total isolation is not feasible, and in fact is rarely needed.
|
|
579
580
|
|
|
580
581
|
- Release **1.3.0** (February, 2024) moves the display of test-loading error messages to a new gold bar that appears at the bottom of the summary when there are any loading errors. A sorting error that occurs when no test files exist yet has also been fixed.
|
|
581
582
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "risei",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Risei 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
5
|
"keywords": [
|
|
6
6
|
"unit test",
|
|
@@ -48,6 +48,6 @@
|
|
|
48
48
|
"fs": "^0.0.1-security",
|
|
49
49
|
"mocha": "^10.0.0",
|
|
50
50
|
"morgan": "~1.9.1",
|
|
51
|
-
"risei": "1.3.
|
|
51
|
+
"risei": "1.3.2"
|
|
52
52
|
}
|
|
53
53
|
}
|