harmonyc 0.16.3 → 0.16.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 +8 -1
- package/code_generator/VitestGenerator.js +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -95,6 +95,14 @@ They are not included in the test case, but the test case name is generated from
|
|
|
95
95
|
|
|
96
96
|
Lines starting with `#` or `//` are comments and are ignored.
|
|
97
97
|
|
|
98
|
+
### Switches
|
|
99
|
+
|
|
100
|
+
You can generate multiple test cases by adding a `{ A / B / C }` syntax into action(s) and possibly response(s).
|
|
101
|
+
|
|
102
|
+
```harmony
|
|
103
|
+
+ password is { "A" / "asdf" / "password123" } => !! "password is too weak"
|
|
104
|
+
```
|
|
105
|
+
|
|
98
106
|
### Error matching
|
|
99
107
|
|
|
100
108
|
You can use `!!` to denote an error response. This will verify that the action throws an error. You can specify the error message after the `!!`.
|
|
@@ -128,7 +136,6 @@ test('T2 - store result in variable', (context) => {
|
|
|
128
136
|
})
|
|
129
137
|
```
|
|
130
138
|
|
|
131
|
-
## Running the tests
|
|
132
139
|
|
|
133
140
|
## License
|
|
134
141
|
|
|
@@ -2,9 +2,9 @@ import { basename } from 'path';
|
|
|
2
2
|
import { Arg, Response, Word, } from "../model/model.js";
|
|
3
3
|
export class VitestGenerator {
|
|
4
4
|
static error(message, stack) {
|
|
5
|
-
return `const e = new SyntaxError(${str(message)});
|
|
6
|
-
e.stack = undefined;
|
|
7
|
-
throw e;
|
|
5
|
+
return `const e = new SyntaxError(${str(message)});
|
|
6
|
+
e.stack = undefined;
|
|
7
|
+
throw e;
|
|
8
8
|
${stack ? `/* ${stack} */` : ''}`;
|
|
9
9
|
}
|
|
10
10
|
constructor(tf, sf) {
|
|
@@ -72,10 +72,10 @@ export class VitestGenerator {
|
|
|
72
72
|
}
|
|
73
73
|
errorStep(action, errorResponse) {
|
|
74
74
|
this.declareFeatureVariables([action]);
|
|
75
|
-
this.tf.print(`context.task.meta.phrases.push(${str(errorResponse.toSingleLineString())});`);
|
|
76
75
|
this.tf.print(`await expect(async () => {`);
|
|
77
76
|
this.tf.indent(() => {
|
|
78
77
|
action.toCode(this);
|
|
78
|
+
this.tf.print(`context.task.meta.phrases.push(${str(errorResponse.toSingleLineString())});`);
|
|
79
79
|
});
|
|
80
80
|
this.tf.print(`}).rejects.toThrow(${(errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.message) !== undefined
|
|
81
81
|
? str(errorResponse.message.text)
|