harmonyc 0.19.0 → 0.20.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/{cli → dist/cli}/cli.js +0 -0
- package/package.json +29 -32
- package/LICENSE +0 -21
- package/README.md +0 -142
- /package/{cli → dist/cli}/cli.d.ts +0 -0
- /package/{cli → dist/cli}/run.d.ts +0 -0
- /package/{cli → dist/cli}/run.js +0 -0
- /package/{cli → dist/cli}/watch.d.ts +0 -0
- /package/{cli → dist/cli}/watch.js +0 -0
- /package/{code_generator → dist/code_generator}/VitestGenerator.d.ts +0 -0
- /package/{code_generator → dist/code_generator}/VitestGenerator.js +0 -0
- /package/{code_generator → dist/code_generator}/outFile.d.ts +0 -0
- /package/{code_generator → dist/code_generator}/outFile.js +0 -0
- /package/{code_generator → dist/code_generator}/test_phrases.d.ts +0 -0
- /package/{code_generator → dist/code_generator}/test_phrases.js +0 -0
- /package/{compiler → dist/compiler}/compile.d.ts +0 -0
- /package/{compiler → dist/compiler}/compile.js +0 -0
- /package/{compiler → dist/compiler}/compiler.d.ts +0 -0
- /package/{compiler → dist/compiler}/compiler.js +0 -0
- /package/{filenames → dist/filenames}/filenames.d.ts +0 -0
- /package/{filenames → dist/filenames}/filenames.js +0 -0
- /package/{model → dist/model}/Router.d.ts +0 -0
- /package/{model → dist/model}/Router.js +0 -0
- /package/{model → dist/model}/model.d.ts +0 -0
- /package/{model → dist/model}/model.js +0 -0
- /package/{optimizations → dist/optimizations}/autoLabel/autoLabel.d.ts +0 -0
- /package/{optimizations → dist/optimizations}/autoLabel/autoLabel.js +0 -0
- /package/{parser → dist/parser}/lexer.d.ts +0 -0
- /package/{parser → dist/parser}/lexer.js +0 -0
- /package/{parser → dist/parser}/lexer_rules.d.ts +0 -0
- /package/{parser → dist/parser}/lexer_rules.js +0 -0
- /package/{parser → dist/parser}/parser.d.ts +0 -0
- /package/{parser → dist/parser}/parser.js +0 -0
- /package/{phrases_assistant → dist/phrases_assistant}/phrases_assistant.d.ts +0 -0
- /package/{phrases_assistant → dist/phrases_assistant}/phrases_assistant.js +0 -0
- /package/{util → dist/util}/indent.d.ts +0 -0
- /package/{util → dist/util}/indent.js +0 -0
- /package/{util → dist/util}/iterators.d.ts +0 -0
- /package/{util → dist/util}/iterators.js +0 -0
- /package/{util → dist/util}/xmur3.d.ts +0 -0
- /package/{util → dist/util}/xmur3.js +0 -0
- /package/{vitest → dist/vitest}/index.d.ts +0 -0
- /package/{vitest → dist/vitest}/index.js +0 -0
package/{cli → dist/cli}/cli.js
RENAMED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,49 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "harmonyc",
|
|
3
|
-
"
|
|
4
|
-
"version": "0.19.0",
|
|
5
|
-
"author": "Bernát Kalló",
|
|
3
|
+
"version": "0.20.0",
|
|
6
4
|
"type": "module",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "tsc",
|
|
7
|
+
"build:watch": "tsc --watch",
|
|
8
|
+
"harmonyc": "tsx ./src/cli/cli",
|
|
9
|
+
"test": "vitest --run",
|
|
10
|
+
"test:compile": "tsx ./src/cli/cli 'src/**/*.harmony'",
|
|
11
|
+
"dev": "vitest --watch",
|
|
12
|
+
"publish": "npm publish",
|
|
13
|
+
"release": "npm run build && release publish"
|
|
9
14
|
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
10
18
|
"exports": {
|
|
11
19
|
"./vitest": {
|
|
12
|
-
"types": "./vitest/index.d.ts",
|
|
13
|
-
"default": "./vitest/index.js"
|
|
20
|
+
"types": "./dist/vitest/index.d.ts",
|
|
21
|
+
"default": "./dist/vitest/index.js"
|
|
14
22
|
}
|
|
15
23
|
},
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
"type": "git",
|
|
19
|
-
"url": "git+https://github.com/harmony-ac/code.git"
|
|
20
|
-
},
|
|
21
|
-
"bugs": {
|
|
22
|
-
"url": "https://github.com/harmony-ac/code/issues"
|
|
24
|
+
"bin": {
|
|
25
|
+
"harmonyc": "./dist/cli/cli.js"
|
|
23
26
|
},
|
|
24
27
|
"dependencies": {
|
|
25
28
|
"fast-glob": "^3.3.2",
|
|
26
29
|
"tinyrainbow": "1",
|
|
30
|
+
"ts-morph": "^27.0.2",
|
|
27
31
|
"typescript-parsec": "0.3.4"
|
|
28
32
|
},
|
|
29
33
|
"optionalDependencies": {
|
|
30
34
|
"watcher": "^2.3.1"
|
|
31
35
|
},
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"model-based testing",
|
|
44
|
-
"test model",
|
|
45
|
-
"test modeling",
|
|
46
|
-
"test modelling",
|
|
47
|
-
"vitest"
|
|
48
|
-
]
|
|
49
|
-
}
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@ossjs/release": "^0.10.0",
|
|
38
|
+
"@types/debug": "^4.1.12",
|
|
39
|
+
"@types/node": "^22.10.6",
|
|
40
|
+
"expect": "^29.7.0",
|
|
41
|
+
"tsx": "^4.7.1",
|
|
42
|
+
"typescript": "^5.3.3",
|
|
43
|
+
"vite": "^7.1.10",
|
|
44
|
+
"vitest": "^3.2.4"
|
|
45
|
+
}
|
|
46
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024-2025 Bernát Kalló
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/README.md
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
# Harmony Code
|
|
2
|
-
|
|
3
|
-
A test design & BDD tool that helps you separate _what_ you test and _how_ you automate it. You write test cases in a simple easy-to-read format, and then automate them with Vitest.
|
|
4
|
-
|
|
5
|
-
## Setup
|
|
6
|
-
|
|
7
|
-
You need to have Node.js installed. Then you can install Harmony Code in your project folder by:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install harmonyc
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Then add it as a plugin to your `vitest.config.js` or `vite.config.js` file, and make sure to include your `.harmony` files:
|
|
14
|
-
|
|
15
|
-
```js
|
|
16
|
-
import harmony from 'harmonyc/vitest'
|
|
17
|
-
|
|
18
|
-
export default {
|
|
19
|
-
plugins: [harmony()],
|
|
20
|
-
include: ['src/**/*.harmony'],
|
|
21
|
-
}
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
This will run .harmony files in vitest.
|
|
25
|
-
|
|
26
|
-
## VSCode plugin
|
|
27
|
-
|
|
28
|
-
Harmony Code has a [VSCode plugin](https://marketplace.visualstudio.com/items?itemName=harmony-ac.harmony-code) that supports syntax highlighting.
|
|
29
|
-
|
|
30
|
-
Harmony Code is compatible with Vitest's VSCode plugin, so you can run and debug tests from the editor.
|
|
31
|
-
|
|
32
|
-
## Syntax
|
|
33
|
-
|
|
34
|
-
A `.harmony` file is a text file with a syntax that looks like this:
|
|
35
|
-
|
|
36
|
-
```
|
|
37
|
-
+ Products API:
|
|
38
|
-
+ Create:
|
|
39
|
-
+ Anonymous:
|
|
40
|
-
- create product => !! "unauthorized"
|
|
41
|
-
+ Admin:
|
|
42
|
-
- authenticate with "admin" => product count `0`
|
|
43
|
-
- create product
|
|
44
|
-
=> product created
|
|
45
|
-
=> product count `1`
|
|
46
|
-
- Delete:
|
|
47
|
-
- delete product => product deleted => product count `0`
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### Indentation
|
|
51
|
-
|
|
52
|
-
The lines of a file are nodes of a tree. The tree is specified with the indentation of the lines, which is n times 2 spaces and a `+` or `-` with one more space. The `+` or `-` sign is considered to be part of the indentation.
|
|
53
|
-
|
|
54
|
-
### Sequences and forks
|
|
55
|
-
|
|
56
|
-
`-` means a sequence: the node follows the previous sibling node and its descendants.
|
|
57
|
-
|
|
58
|
-
`+` means a fork: the node directly follows its parent node. All siblings with `+` are separate branches, they will generate separate scenarios.
|
|
59
|
-
|
|
60
|
-
### Phrases (actions and responses)
|
|
61
|
-
|
|
62
|
-
After the mark, every node can contain an **action** and zero or more **responses**, together called **phrases**. The action is the text before the `=>`, and the responses are the text after the `=>`.
|
|
63
|
-
|
|
64
|
-
Both actions and responses get compiled to simple function calls - in JavaScript, awaited function calls. Actions will become `When_*` functions, and responses will become `Then_*` functions. The return value of the action is passed to the responses of the same step as the last argument.
|
|
65
|
-
|
|
66
|
-
### Arguments
|
|
67
|
-
|
|
68
|
-
Phrases (actions and responses) can have arguments which are passed to the implementation function. There are two types of arguments: strings and code fragments:
|
|
69
|
-
|
|
70
|
-
```harmony
|
|
71
|
-
+ strings:
|
|
72
|
-
+ hello "John"
|
|
73
|
-
+ code fragment:
|
|
74
|
-
+ greet `3` times
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
becomes
|
|
78
|
-
|
|
79
|
-
```javascript
|
|
80
|
-
test('T1 - strings', async () => {
|
|
81
|
-
const P = new Phrases()
|
|
82
|
-
await P.When_hello_('John')
|
|
83
|
-
})
|
|
84
|
-
test('T2 - code fragment', async () => {
|
|
85
|
-
const P = new Phrases()
|
|
86
|
-
await P.When_greet__times(3)
|
|
87
|
-
})
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Labels
|
|
91
|
-
|
|
92
|
-
Labels are lines that start with `-` or `+` and end with `:`. You can use them to structure your test design.
|
|
93
|
-
They are not included in the test case, but the test case name is generated from the labels.
|
|
94
|
-
|
|
95
|
-
### Comments
|
|
96
|
-
|
|
97
|
-
Lines starting with `#` or `//` are comments and are ignored.
|
|
98
|
-
|
|
99
|
-
### Switches
|
|
100
|
-
|
|
101
|
-
You can generate multiple test cases by adding a `{ A / B / C }` syntax into action(s) and possibly response(s).
|
|
102
|
-
|
|
103
|
-
```harmony
|
|
104
|
-
+ password is { "A" / "asdf" / "password123" } => !! "password is too weak"
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### Error matching
|
|
108
|
-
|
|
109
|
-
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 `!!`.
|
|
110
|
-
|
|
111
|
-
### Variables
|
|
112
|
-
|
|
113
|
-
You can set variables in the tests and use them in strings and code fragments:
|
|
114
|
-
|
|
115
|
-
```
|
|
116
|
-
+ set variable:
|
|
117
|
-
+ ${name} "John"
|
|
118
|
-
+ greet "${name}" => "hello John"
|
|
119
|
-
+ store result into variable:
|
|
120
|
-
+ run process => ${result}
|
|
121
|
-
+ "${result}" is "success"
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
becomes
|
|
125
|
-
|
|
126
|
-
```javascript
|
|
127
|
-
test('T1 - set variable', (context) => {
|
|
128
|
-
const P = new Phrases();
|
|
129
|
-
(context.task.meta.variables ??= {})['name'] = "John";
|
|
130
|
-
await P.When_greet_(context.task.meta.variables?.['name']);
|
|
131
|
-
})
|
|
132
|
-
test('T2 - store result in variable', (context) => {
|
|
133
|
-
const P = new Phrases();
|
|
134
|
-
const r = await P.When_run_process();
|
|
135
|
-
(context.task.meta.variables ??= {})['result'] = r;
|
|
136
|
-
await P.Then__is_(`${context.task.meta.variables?.['result']});
|
|
137
|
-
})
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
## License
|
|
141
|
-
|
|
142
|
-
MIT
|
|
File without changes
|
|
File without changes
|
/package/{cli → dist/cli}/run.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|