risei 1.1.2 → 1.2.0

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
@@ -8,11 +8,7 @@
8
8
  * Refactor or replace existing designs without worrying about the cost in past or future test time.
9
9
  * Create tests with immediate confidence, because you can't introduce mistakes in test code you write.
10
10
 
11
- > Risei is under active development.  To see the latest changes, check out [What's new in Risei](#whats-new-in-risei).
12
- >
13
- > For a list of any known bugs and workarounds, see [Known bugs and workarounds](#known-bugs-and-workarounds).  To see which JavaScript features Risei doesn't address yet, check out [Limitations in Risei](#limitations-in-risei).
14
-
15
- Risei may be referred to as **Rs** here for brevity.  A dotted `.name` here means a property, just like a `name()` with parens is a method or function.
11
+ Risei may be referred to as **Rs** here for brevity.
16
12
 
17
13
 
18
14
 
@@ -31,9 +27,12 @@ Here is the terminal output of these two example tests.  Tests are grouped
31
27
  ![https://deusware.com/Output-example.png](https://deusware.com/Output-example.png)
32
28
 
33
29
 
34
- 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. 
30
+ - An individual test may appear on one line or multiple lines, depending on how wide the terminal window is.
31
+ - Any failing tests appear in light red.
32
+ - Your latest-edited tests always sort to the bottom, so you can see your current test results at a glance.
33
+
35
34
 
36
- Test runs also feature a title bar, as well as a summary bar at the bottom:
35
+ Test runs also feature a title bar at the top, as well as a summary bar at the bottom:
37
36
 
38
37
  ![https://deusware.com/Summary-example.png](https://deusware.com/Summary-example.png)
39
38
 
@@ -42,6 +41,8 @@ Test runs also feature a title bar, as well as a summary bar at the bottom:
42
41
 
43
42
  ## Using Risei
44
43
 
44
+ Risei is under active development.  If you've been here before, check out [what's new in Risei](#whats-new-in-risei) for the latest.  Also see [known bugs and workarounds](#known-bugs-and-workarounds) and [limitations in Risei](#limitations-in-risei).
45
+
45
46
  ### Installation
46
47
 
47
48
  Install Risei for development time only:
@@ -160,9 +161,7 @@ Or write a `package.json` script that does the same:
160
161
 
161
162
  ```json
162
163
  "scripts": {
163
- ...
164
- "test": "node ./node_modules/risei/index.js",
165
- ...
164
+ "test": "node ./node_modules/risei/index.js"
166
165
  }
167
166
  ```
168
167
 
@@ -475,8 +474,7 @@ Most problems with using Risei are minor mistakes in syntax, or omissions in tes
475
474
  | `"Test loading failed for... SyntaxError: Unexpected token ':'"` | Missing comma in your tests in the named file |
476
475
  | `"Test loading failed for... SyntaxError: Unexpected token '.'"` | Using `this.tests = []` instead of `tests = []` in the file named |
477
476
  | Other `... Unexpected token ...` errors | Some other syntax error in the file named, most likely a missing or extra delimiter |
478
- | Unexpected actual values, or unexpected passes / fails in test runs | Spoofs, retrievals, or special conditions from previous tests not replaced or reset with `[ ]`<br>&mdash; or &mdash;<br>Tested method mutates `.in` or `.with` args: preventable by using a function to supply those args<br>&mdash; or &mdash;<br>Pre-listed test properties produce extra tests: preventable by restating class in `.on`
479
- |
477
+ | Unexpected actual values, or unexpected passes / fails in test runs | Spoofs, retrievals, or special conditions from previous tests not replaced or reset with `[ ]`<br>&mdash; or &mdash;<br>Tested method mutates `.in` or `.with` args: preventable by using a function to supply those args<br>&mdash; or &mdash;<br>Pre-listed test properties produce extra tests: preventable by restating class in `.on` |
480
478
 
481
479
 
482
480
 
@@ -507,14 +505,15 @@ One known unexpected result (not quite a bug) exists:
507
505
 
508
506
  ## What's new in Risei
509
507
 
510
- Release **1.1.2** of Risei (January, 2024) fixes two problems:
511
- - Classes were sometimes displayed in output as their entire definition, instead of just the class name.
512
- - All `Date` instances were considered equal, regardless of their actual value.
508
+ - Release **1.2.0** (January, 2024) changes sorting of test files.&nbsp; Previously they were displayed in the order found.&nbsp; Now the last-edited file is moved to the bottom, making it easy to see the latest test results.
509
+
513
510
 
514
- Development of Risei is ongoing, including internal improvements, problem fixes, and additional options for testing.
511
+ - Release **1.1.2** of Risei (January, 2024) fixes two problems:
512
+ - Classes were sometimes displayed in output as their entire definition.&nbsp; Now just the class name is displayed.
513
+ - All `Date` instances were considered equal, regardless of their actual value.&nbsp; Now they only are considered equal when they actually are.
515
514
 
516
515
 
517
- > Do not use release **1.1.1**, because it contains an internal path error.
516
+ > Don't use release **1.1.1**, which contains an internal path error.
518
517
 
519
518
 
520
519
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "risei",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
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",
@@ -28,7 +28,8 @@
28
28
  "test": "clear; node ./node_modules/risei/index.js"
29
29
  },
30
30
  "risei": {
31
- "tests": "**.rt.js"
31
+ "tests": "**.rt.js",
32
+ "sort": "normal"
32
33
  },
33
34
  "exports": {
34
35
  ".": "./index.js",
package/system/Risei.js CHANGED
@@ -69,7 +69,7 @@ console.log();
69
69
 
70
70
  // Test-system objects and their relationships.
71
71
  const finder = new ChosenTestFinder();
72
- const runner = new TestRunner(finder.findAllTests());
72
+ const runner = new TestRunner();
73
73
  const reporter = new TerminalReporter();
74
74
 
75
75
  const caller = new LocalCaller(finder, runner, reporter);
@@ -35,12 +35,14 @@ export class TestFinder extends ATestFinder {
35
35
  let source = this.sourceBySearch();
36
36
  this.#sought = source.tests;
37
37
  let testPaths = this.pathsFromTargetingSource();
38
-
38
+
39
+ testPaths = this.sortTestPaths(testPaths);
40
+
39
41
  let tests = [];
40
42
 
41
43
  for (let testPath of testPaths) {
42
44
  // Contents of test sources have to be loaded.
43
- let sources = await this.convertPathToClassInstances(testPath);
45
+ let sources = await this.convertPathToClassInstances(testPath.path);
44
46
 
45
47
  // Any test classes in each source have to be loaded.
46
48
  for (let source of sources) {
@@ -99,7 +101,9 @@ export class TestFinder extends ATestFinder {
99
101
  // This level: any test files.
100
102
  if (entry.isFile()) {
101
103
  if (minimatch(entry.path, this.#sought, { matchBase: true })) {
102
- paths.push(entry.path);
104
+ // Test file's last-edited time stored with path for some sortings.
105
+ let stats = fs.statSync(entry.path);
106
+ paths.push({ path: entry.path, changed: stats.mtimeMs });
103
107
  }
104
108
  }
105
109
 
@@ -110,6 +114,18 @@ export class TestFinder extends ATestFinder {
110
114
  }
111
115
  }
112
116
 
117
+ sortTestPaths(testPaths) /* passed */ {
118
+ // Latest is found for placing at end.
119
+ let latest = testPaths.reduce((prior, now) => { return now.changed > prior.changed ? now : prior; });
120
+
121
+ // Copy made with latest removed, which is added at end.
122
+ let sorted = testPaths.filter(x => x !== latest);
123
+ sorted.push(latest);
124
+
125
+ // Back to caller.
126
+ return sorted;
127
+ }
128
+
113
129
  async convertPathToClassInstances(classPath) {
114
130
  // Each test source may have multiple test classes.
115
131
  let testSources = [];
@@ -259,7 +259,7 @@ export class TestRunner {
259
259
  this.#numberFailed++;
260
260
  }
261
261
 
262
- this.#allDidPass &= test.didPass;
262
+ this.#allDidPass &&= test.didPass;
263
263
  }
264
264
 
265
265
  // endregion Dependencies of runOneTest()