harmonyc 0.6.0-3 → 0.6.0-5

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
@@ -6,13 +6,13 @@ A test design & BDD tool that helps you separate the _what_ to test from the _ho
6
6
 
7
7
  - ### watch and run mode
8
8
 
9
- - You can compile and run your `*.spec.md` files in the `src` folder, and watch it, by running
9
+ - You can compile and run your `*.harmony.md` files in the `src` folder, and watch it, by running
10
10
 
11
11
  ```bash script
12
- npx harmonyc --run --watch 'src/**/*.spec.md'
12
+ npx harmonyc --run --watch 'src/**/*.harmony.md'
13
13
  ```
14
14
 
15
- - => this will generate tests into `*.spec.mjs` files
15
+ - => this will generate tests into `*.test.mjs` files
16
16
  - => this will create a stub `*.steps.ts` file if it doesn't exist
17
17
 
18
18
  ## Syntax
package/compile.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import { NodeTest } from './languages/JavaScript.js';
2
2
  import { OutFile } from './outFile.js';
3
3
  import { parse } from './syntax.js';
4
+ import { stepsFileName, testFileName } from './filenames/filenames.js';
4
5
  export function compileFeature(fileName, src) {
5
6
  const feature = parse({ fileName, src });
6
- const outFn = `${fileName.replace(/\.[a-z]+$/i, '')}.mjs`;
7
+ const outFn = testFileName(fileName);
7
8
  const outFile = new OutFile(outFn);
8
- const stepsFn = outFn.replace(/(\.(spec|test)s?)?\.[a-z]+$/i, '.steps.ts');
9
+ const stepsFn = stepsFileName(fileName);
9
10
  const stepsFile = new OutFile(stepsFn);
10
11
  const cg = new NodeTest(outFile, stepsFile);
11
12
  feature.toCode(cg);
@@ -0,0 +1,15 @@
1
+ import glob from 'fast-glob';
2
+ const { globSync } = glob;
3
+ export function base(fn) {
4
+ return fn.replace(/\.harmony\.md$/i, '');
5
+ }
6
+ export function testFileName(fn) {
7
+ return base(fn) + '.test.mjs';
8
+ }
9
+ export function stepsFileName(fn) {
10
+ const existing = globSync(base(fn) + '.steps.*');
11
+ if (existing.length) {
12
+ return existing.sort()[0];
13
+ }
14
+ return base(fn) + '.steps.ts';
15
+ }
package/js_api/js_api.js CHANGED
@@ -28,7 +28,7 @@ class FeatureContext {
28
28
  const matches = __classPrivateFieldGet(this, _FeatureContext_actions, "f").map((def) => def.expr.match(s));
29
29
  const matching = [...matches.keys()].filter((i) => matches[i]);
30
30
  if (matching.length === 0) {
31
- throw new Error(`Not defined: ${s}`);
31
+ throw new Error(`Action not defined: ${s}`);
32
32
  }
33
33
  if (matching.length > 1) {
34
34
  throw new Error(`Ambiguous: ${s}\n${matching
@@ -50,7 +50,7 @@ class FeatureContext {
50
50
  const matches = __classPrivateFieldGet(this, _FeatureContext_responses, "f").map((def) => def.expr.match(s));
51
51
  const matching = [...matches.keys()].filter((i) => matches[i]);
52
52
  if (matching.length === 0) {
53
- throw new Error(`Not defined: ${s}`);
53
+ throw new Error(`Response not defined: ${s}`);
54
54
  }
55
55
  if (matching.length > 1) {
56
56
  throw new Error(`Ambiguous: ${s}\n${matching
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "harmonyc",
3
3
  "description": "Harmony Code - model-driven BDD for Vitest",
4
- "version": "0.6.0-3",
4
+ "version": "0.6.0-5",
5
5
  "author": "Bernát Kalló",
6
6
  "type": "module",
7
7
  "bin": {