risei 1.0.0 → 1.0.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 +40 -35
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,25 +18,25 @@ Here are two example tests. `SortModel.countSort()` is being tested with
|
|
|
18
18
|
|
|
19
19
|
<div style="padding-left: 1.5rem">
|
|
20
20
|
|
|
21
|
-

|
|
22
22
|
|
|
23
23
|
</div>
|
|
24
24
|
|
|
25
|
-
Here is the terminal output of these two example tests. Tests are grouped by class and method.
|
|
25
|
+
Here is the terminal output of these two example tests. Tests are grouped by class and method. Inputs, expected, and actual values are displayed for all tests, to make intended usage obvious at a glance:
|
|
26
26
|
|
|
27
27
|
<div style="padding-left: 1.5rem;">
|
|
28
28
|
|
|
29
|
-

|
|
30
30
|
|
|
31
31
|
</div>
|
|
32
32
|
|
|
33
|
-
An individual test may appear on one line or multiple lines, depending on how wide the terminal window is. Any failing tests appear in
|
|
33
|
+
An individual test may appear on one line or multiple lines, depending on how wide the terminal window is. Any failing tests appear in light red.
|
|
34
34
|
|
|
35
|
-
Test runs also feature a title bar,
|
|
35
|
+
Test runs also feature a title bar, as well as a summary bar at the bottom:
|
|
36
36
|
|
|
37
37
|
<div style="padding-left: 1.5rem;">
|
|
38
38
|
|
|
39
|
-

|
|
40
40
|
|
|
41
41
|
</div>
|
|
42
42
|
|
|
@@ -59,10 +59,10 @@ npm install --save-dev risei
|
|
|
59
59
|
</summary>
|
|
60
60
|
<br>
|
|
61
61
|
|
|
62
|
-
- RiseiJs is an `npm` package that uses ESM syntax. It only works well with modern versions of Node that automatically support ESM
|
|
62
|
+
- RiseiJs is an `npm` package that uses ESM syntax. It only works well with modern versions of Node that automatically support ESM.
|
|
63
63
|
- Although ESM is usable with older Node versions using external workarounds, a modern version is highly recommended, and Rjs is not guaranteed to work with older versions.
|
|
64
|
-
- You can install Rjs as a regular dependency if you want using `npm install risei`, but ordinarily this doesn't make sense, and exposing tests in production is generally considered a bad practice.
|
|
65
|
-
- RiseiJs doesn't directly add any security risks to your code, but exposing tests that use it might (as
|
|
64
|
+
- You can install Rjs as a regular dependency if you want, using `npm install risei`, but ordinarily this doesn't make sense, and exposing tests in production is generally considered a bad practice.
|
|
65
|
+
- RiseiJs doesn't directly add any security risks to your code, but exposing tests that use it might (as it can with other test frameworks).
|
|
66
66
|
|
|
67
67
|
</details>
|
|
68
68
|
|
|
@@ -86,8 +86,8 @@ npm install --save-dev risei
|
|
|
86
86
|
</summary>
|
|
87
87
|
<br>
|
|
88
88
|
|
|
89
|
-
-
|
|
90
|
-
-
|
|
89
|
+
- The extension `.rt.js` is standard, but you can actually use any extension you want.
|
|
90
|
+
- Whatever extension you use, it should be unique, to avoid scanning many extra files for tests at each test run.
|
|
91
91
|
|
|
92
92
|
</details>
|
|
93
93
|
|
|
@@ -101,8 +101,7 @@ npm install --save-dev risei
|
|
|
101
101
|
</summary>
|
|
102
102
|
<br>
|
|
103
103
|
|
|
104
|
-
-
|
|
105
|
-
- Whether you use the standard extension or not, use a unique one to avoid scanning all of your files for tests at each test run.
|
|
104
|
+
- If you chose another extension for your unit-test files (covered earlier), use that instead here.
|
|
106
105
|
|
|
107
106
|
</details>
|
|
108
107
|
|
|
@@ -129,16 +128,16 @@ export TargetClassTests extends ATestSource {
|
|
|
129
128
|
</summary>
|
|
130
129
|
<br>
|
|
131
130
|
|
|
132
|
-
-
|
|
131
|
+
- Tests must be placed in subclasses of `ATestSource`.
|
|
133
132
|
- RiseiJs looks for this class relationship internally, so duck-typing does not work.
|
|
134
|
-
- You have to `import` the class/es
|
|
133
|
+
- You have to `import` the class/es being tested in the file/s containing their tests.
|
|
135
134
|
- Don't use ✗`this.tests` by accident — it just causes an exception when tests are run.
|
|
136
135
|
|
|
137
136
|
</details>
|
|
138
137
|
|
|
139
138
|
|
|
140
139
|
|
|
141
|
-
5. Write each test as a JavaScript object literal in the array
|
|
140
|
+
5. Write each test as a JavaScript object literal in the array, using RiseiJs' simple, light syntax:
|
|
142
141
|
|
|
143
142
|
<div style="padding-left: 1.5rem;">
|
|
144
143
|
|
|
@@ -165,7 +164,7 @@ export TargetClassTests extends ATestSource {
|
|
|
165
164
|
|--------|--------------------------------------------------------------------------|
|
|
166
165
|
| `on` | The class under test, as a symbol (already imported into the test file) |
|
|
167
166
|
| `with` | An array of any arguments to pass to the constructor of the tested class |
|
|
168
|
-
| `of` | The name of the method under test, as a string, no `()`
|
|
167
|
+
| `of` | The name of the method under test, as a string, no `()` needed |
|
|
169
168
|
| `for` | A description of what the test proves, for test output |
|
|
170
169
|
| `in` | An array of the input arguments to pass to the tested method |
|
|
171
170
|
| `out` | The expected return value, not in an array |
|
|
@@ -176,8 +175,7 @@ export TargetClassTests extends ATestSource {
|
|
|
176
175
|
- When there are no inputs to a method, use an empty array `[ ]` for `.in`.
|
|
177
176
|
- When the output of a method is an array, freely use an array for `.out`.
|
|
178
177
|
- When there is no output to a method, put the expected value in `.out`, and use special syntax to get the actual value to compare it with (covered later).
|
|
179
|
-
- The property names were chosen to be easy to remember and type
|
|
180
|
-
- There are different, long names available to use for each property if wanted (covered later). None of them are JavaScript keywords.
|
|
178
|
+
- The property names were chosen to be easy to remember and type, but longer alternatives are available (covered later).
|
|
181
179
|
|
|
182
180
|
</div>
|
|
183
181
|
|
|
@@ -185,7 +183,7 @@ export TargetClassTests extends ATestSource {
|
|
|
185
183
|
|
|
186
184
|
|
|
187
185
|
|
|
188
|
-
6. Write more tests with less syntax by defining
|
|
186
|
+
6. Write more tests with less syntax, by defining properties that are automatically reused in upcoming tests, and/or setting only the properties in a test that are different from the previous test/s:
|
|
189
187
|
|
|
190
188
|
<div style="padding-left: 1.5rem;">
|
|
191
189
|
|
|
@@ -212,17 +210,18 @@ export TargetClassTests extends ATestSource {
|
|
|
212
210
|
</summary>
|
|
213
211
|
<br>
|
|
214
212
|
|
|
215
|
-
-
|
|
216
|
-
- Changing the method under test with a new `.of` wipes out only test properties related to methods, to preserve class values you usually want.
|
|
217
|
-
- You can change individual test properties such as `.with` whenever you want, but by design, they don't revert in the next test.
|
|
218
|
-
- This simplification tactic, called _collapsing forward_, saves a lot of typing and reading.
|
|
213
|
+
- This simplification tactic, called _collapsing forward_, saves a lot of typing and makes reading tests much easier.
|
|
219
214
|
- Individual tests remain isolated because class instances, spoofed methods (covered later) and so on are all created anew for each test.
|
|
215
|
+
- Test contents are partially or fully reset when it makes the most sense:
|
|
216
|
+
- Changing the class under test in `.on` wipes out all prior test properties, so the new class has a fresh start.
|
|
217
|
+
- Changing the method under test with a new `.of` wipes out only test properties related to methods, to preserve class values you usually want.
|
|
218
|
+
- You can also change individual test properties such as `.with` whenever you want just by stating a new value — but by design, they are collapsed forward to following tests.
|
|
220
219
|
|
|
221
220
|
</details>
|
|
222
221
|
|
|
223
222
|
|
|
224
223
|
|
|
225
|
-
7. To isolate any tests with dependencies,
|
|
224
|
+
7. To isolate any tests with dependencies, you define test-only results for the methods depended on using _spoofing_, which is similar to mocks or fakes, but easier to use. Definitions for spoofs are set in the `.plus` property:
|
|
226
225
|
|
|
227
226
|
<div style="padding-left: 1.5rem;">
|
|
228
227
|
|
|
@@ -261,7 +260,7 @@ export TargetClassTests extends ATestSource {
|
|
|
261
260
|
|
|
262
261
|
</div>
|
|
263
262
|
|
|
264
|
-
- You can leave out `.as` when you don't need a return value.
|
|
263
|
+
- You can leave out `.as` when you don't need a return value. In that case, an empty method is used (that is, `() => { }`).
|
|
265
264
|
- When necessary, you can provide a function to use in place of the real code, in `.as`.
|
|
266
265
|
|
|
267
266
|
|
|
@@ -541,7 +540,9 @@ When the contents of `.from` are a function, these are the two parameters:
|
|
|
541
540
|
|
|
542
541
|
### Property long names
|
|
543
542
|
|
|
544
|
-
|
|
543
|
+
Property names are short so they're easy to use. Some of them overlap with JavaScript keywords, but this causes no harm.
|
|
544
|
+
|
|
545
|
+
All test properties have long names that you can use instead of the short ones if you prefer, mixed together as much as you want. None of the long names are JavaScript keywords.
|
|
545
546
|
|
|
546
547
|
|
|
547
548
|
<details>
|
|
@@ -608,19 +609,23 @@ The following are not supported at present:
|
|
|
608
609
|
|
|
609
610
|
Most problems with using RiseiJs are minor mistakes in syntax, or omissions in test definitions:
|
|
610
611
|
|
|
611
|
-
| Error text
|
|
612
|
-
|
|
613
|
-
| `"Test loading failed for... SyntaxError: Unexpected token ':'"`
|
|
614
|
-
| `"Test loading failed for... SyntaxError: Unexpected token '.'"
|
|
615
|
-
| Other `... Unexpected token ...` errors
|
|
616
|
-
| Unexpected actual values
|
|
612
|
+
| Error text | Probable cause / fix |
|
|
613
|
+
|---------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|
|
|
614
|
+
| `"Test loading failed for... SyntaxError: Unexpected token ':'"` | A comma is missing in your tests in the file named. |
|
|
615
|
+
| `"Test loading failed for... SyntaxError: Unexpected token '.'"` | You used `this.tests = []` instead of `tests = []` in the file named. |
|
|
616
|
+
| Other `... Unexpected token ...` errors | There is some other syntax error in the file named, most likely a missing or extra delimiter. |
|
|
617
|
+
| Unexpected actual values, or unexpected passes / fails in test runs | Spoofs, retrievals, or other special conditions from previous tests haven't been replaced / reset.
|
|
617
618
|
|
|
618
619
|
Usually when something is wrong in one test file, other test files still load and run, so a good sign of problems is a sudden decrease in the number of run tests reported.
|
|
619
620
|
|
|
620
621
|
|
|
621
|
-
##
|
|
622
|
+
## Who is behind RiseiJs
|
|
623
|
+
|
|
624
|
+
RiseiJs is made by Ed Fallin, a longtime software developer proficient in many technologies, with a knack for finding new answers to old questions.
|
|
625
|
+
|
|
626
|
+
If you find RiseiJs useful, consider spreading the word to other devs, making a donation, suggesting enhancements, or proposing sponsorships.
|
|
622
627
|
|
|
623
|
-
|
|
628
|
+
You can get in touch about Rjs using **riseijsmaker@gmail.com**.
|
|
624
629
|
|
|
625
630
|
|
|
626
631
|
## What the RiseiJs license is
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "risei",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
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
5
|
"keywords":[ "unit test", "test", "values", "objects", "easy", "fast" ],
|
|
6
6
|
"author": "Ed Fallin <riseijsmaker@gmail.com>",
|