example-test-gen 1.0.0-prerelease-2026-03-31
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 +54 -0
- package/dist/builtins.d.ts +8 -0
- package/dist/builtins.d.ts.map +1 -0
- package/dist/builtins.js +42 -0
- package/dist/builtins.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +117 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +3 -0
- package/dist/config.js.map +1 -0
- package/dist/extractor.d.ts +25 -0
- package/dist/extractor.d.ts.map +1 -0
- package/dist/extractor.js +71 -0
- package/dist/extractor.js.map +1 -0
- package/dist/generator.d.ts +3 -0
- package/dist/generator.d.ts.map +1 -0
- package/dist/generator.js +26 -0
- package/dist/generator.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +22 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# example-test-gen
|
|
2
|
+
|
|
3
|
+
Generate test files from `@example` snippets in your code.
|
|
4
|
+
|
|
5
|
+
[ UNDER CONSTRUCTION ] 2026-03-31 - This package is still being built! Tune in later!
|
|
6
|
+
|
|
7
|
+
## Contents
|
|
8
|
+
|
|
9
|
+
- [Overview](#overview)
|
|
10
|
+
- [Requirements](#requirements)
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
`example-test-gen` extracts test code from JSDoc `@example` annotations and generates runnable test files.
|
|
15
|
+
|
|
16
|
+
## Requirements
|
|
17
|
+
|
|
18
|
+
These requirements have been rewritten and defined since the core code was initially created.
|
|
19
|
+
When implementing new features or modifying existing ones, please refer to these requirements to ensure compliance.
|
|
20
|
+
|
|
21
|
+
The existing code should be updated to meet these requirements where applicable.
|
|
22
|
+
|
|
23
|
+
| ID | Requirement (plain language) | Test Pattern(s) | User Reviewed | Tests Completed |
|
|
24
|
+
|----|------------------------------|-----------------|---------------|-----------|
|
|
25
|
+
| **CLI01** | **CLI Entry**: Executable as `npx example-test-gen` with `--help` and `--version` flags | End-to-end CLI tests via @example in `cli.ts` | [x] | [x] |
|
|
26
|
+
| **CLI02** | **Built-in Configs**: Support `--config=jest` and `--config=vitest` for zero-config test generation | End-to-end CLI tests via @example in `cli.ts` | [x] | [x] |
|
|
27
|
+
| **CLI03** | **Custom Config Path**: Support `--config=./path.mjs` for user-defined config files | End-to-end CLI tests via @example in `cli.ts` | [x] | [x] |
|
|
28
|
+
| **CLI04** | **CLI Error Handling**: Clear error messages for missing config, invalid config paths, and config load failures | End-to-end CLI tests via @example in `cli.ts` | [x] | [x] |
|
|
29
|
+
| **CLI05** | **CLI Files Override**: Support `--files` flag for ad-hoc file selection without config file (e.g., `--files="src/**/*.ts"` or `--files="src/a.ts,src/b.ts"`) | End-to-end CLI tests via @example in `cli.ts` | [x] | [x] |
|
|
30
|
+
| **CLI06** | **CLI Output Directory**: Support `--outDir` flag to override the default output directory (e.g., `--outDir=./generated-tests`) | End-to-end CLI tests via @example in `cli.ts` | [x] | [x] |
|
|
31
|
+
| **SDK01** | **Programmatic API**: Export `generateTests()` function as primary entry point | Contract tests via @example in `index.ts` | [x] | [ ] |
|
|
32
|
+
| **SDK02** | **API Types**: Export TypeScript types (`SnippetInfo`, `MapperResult`, `MapperFn`, `Config`) | Contract tests via @example in `index.ts` | [x] | [ ] |
|
|
33
|
+
| **SDK03** | **Built-in Mappers Export**: Export `jestMapper` and `vitestMapper` for SDK consumers | Contract tests via @example in `builtins.ts` | [x] | [ ] |
|
|
34
|
+
| **SDK04** | **Config Object Support**: Accept `files` (string or string[] with glob support), `mapper` (function or built-in name), and `outDir` (string) | Integration tests via @example in `config.ts` | [x] | [ ] |
|
|
35
|
+
| **SDK05** | **Config Validation**: Validate required fields (`files`, `mapper` or built-in ref) with helpful error messages | Unit tests via @example in `config.ts` | [x] | [ ] |
|
|
36
|
+
| **CORE01** | **Source Discovery**: Find source files from `files` glob(s) (supports `**/*` style paths) | Unit tests via @example in `extractor.ts` | [x] | [ ] |
|
|
37
|
+
| **CORE02** | **@example Extraction**: Extract code snippets from JSDoc `@example` blocks | Unit tests via @example in `extractor.ts` | [x] | [ ] |
|
|
38
|
+
| **CORE03** | **Snippet Parsing**: Parse optional description, code fence language hint, and snippet body | Unit tests via @example in `extractor.ts` | [x] | [ ] |
|
|
39
|
+
| **CORE04** | **Import Extraction**: Identify and separate ES module imports from executable code in snippets | Unit tests via @example in `extractor.ts` | [x] | [ ] |
|
|
40
|
+
| **CORE05** | **Multiple Snippets**: Detect and extract all @example blocks when multiple are present in a single source file | Unit tests via @example in `extractor.ts` | [x] | [ ] |
|
|
41
|
+
| **TRANS01** | **Jest Mapper**: Wrap snippets in `describe`/`it` blocks with Jest-compatible imports | Unit tests via @example in `builtins.ts` | [x] | [ ] |
|
|
42
|
+
| **TRANS02** | **Vitest Mapper**: Wrap snippets in `describe`/`it` blocks with Vitest-compatible imports | Unit tests via @example in `builtins.ts` | [x] | [ ] |
|
|
43
|
+
| **TRANS03** | **Output Header**: Include source file path, description, and auto-generated notice in test file header (remove "Snippet:" section) | Unit tests via @example in `builtins.ts` | [x] | [ ] |
|
|
44
|
+
| **TRANS04** | **Output Structure**: Separate imports section from test body; deduplicate imports | Unit tests via @example in `builtins.ts` | [x] | [ ] |
|
|
45
|
+
| **TRANS05** | **Import Path Transformation**: Rewrite relative imports (`./foo.ts`) to be valid from test file location (`../src/foo.js`) | Unit tests via @example in `builtins.ts` | [x] | [ ] |
|
|
46
|
+
| **TRANS06** | **Output Directory Mirroring**: Write generated tests to `outDir` preserving relative directory structure (`src/foo.ts` → `tests/foo.test.ts`) | Integration tests via @example in `config.ts` | [x] | [ ] |
|
|
47
|
+
| **TRANS07** | **File Overwriting**: Overwrite existing test files without prompting; idempotent generation | Integration tests via @example in `config.ts` | [x] | [ ] |
|
|
48
|
+
| **TRANS08** | **Auto Source Import**: Generated test files automatically import all exports from the source file, removing the need for users to manually import the method-under-test in their @example blocks | Unit tests via @example in `builtins.ts` | [x] | [ ] |
|
|
49
|
+
| **META01** | **Self-Testing**: Library generates and runs its own tests via `@example` annotations (dogfooding) | @example in all source files, generated to `tests/` | [x] | [ ] |
|
|
50
|
+
|
|
51
|
+
**Requirement Notes:**
|
|
52
|
+
- **TRANS05**: When the Vitest/Jest mapper generates tests in `tests/` directory, it must transform `import { x } from './src/foo.ts'` in the snippet to `import { x } from '../src/foo.js'` (or equivalent) in the output
|
|
53
|
+
- **TRANS06**: Config should support `outDir: 'tests'` which mirrors source structure (`src/foo.ts` → `tests/foo.test.ts`)
|
|
54
|
+
- **SDK05**: Config validation should check required fields (`files`, `mapper` or built-in ref) and provide helpful error messages
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MapperFunction } from './types.js';
|
|
2
|
+
export declare function createJestMapper(): MapperFunction;
|
|
3
|
+
export declare function createVitestMapper(): MapperFunction;
|
|
4
|
+
export declare const builtInConfigs: Record<string, {
|
|
5
|
+
pattern: string | string[];
|
|
6
|
+
mapper: MapperFunction;
|
|
7
|
+
}>;
|
|
8
|
+
//# sourceMappingURL=builtins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtins.d.ts","sourceRoot":"","sources":["../src/builtins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,wBAAgB,gBAAgB,IAAI,cAAc,CAcjD;AAED,wBAAgB,kBAAkB,IAAI,cAAc,CAcnD;AAED,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,cAAc,CAAA;CAAE,CASjG,CAAC"}
|
package/dist/builtins.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.builtInConfigs = void 0;
|
|
4
|
+
exports.createJestMapper = createJestMapper;
|
|
5
|
+
exports.createVitestMapper = createVitestMapper;
|
|
6
|
+
function createJestMapper() {
|
|
7
|
+
return ({ imports, snippet, description, dir, filename }) => {
|
|
8
|
+
const testName = filename.replace(/\.(ts|js|tsx|jsx|mjs|cjs)$/, '');
|
|
9
|
+
const outputDir = dir || '.';
|
|
10
|
+
const itDescription = description ?? 'example test';
|
|
11
|
+
const importSection = imports.length > 0 ? imports.join('\n') + '\n\n' : '';
|
|
12
|
+
const header = `// Generated test from @example snippet\n// Source: ${dir ? dir + '/' : ''}${filename}\n\n`;
|
|
13
|
+
return {
|
|
14
|
+
output: `${header}${importSection}describe('${testName}', () => {\n it('${itDescription}', async () => {\n${snippet.split('\n').map(line => ' ' + line).join('\n')}\n });\n});`,
|
|
15
|
+
filepath: `${outputDir}/${testName}.test.js`
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function createVitestMapper() {
|
|
20
|
+
return ({ imports, snippet, description, dir, filename }) => {
|
|
21
|
+
const testName = filename.replace(/\.(ts|js|tsx|jsx|mjs|cjs)$/, '');
|
|
22
|
+
const outputDir = dir || '.';
|
|
23
|
+
const itDescription = description ?? `${testName} example`;
|
|
24
|
+
const importSection = imports.length > 0 ? imports.join('\n') + '\n\n' : '';
|
|
25
|
+
const header = `// Generated test from @example snippet\n// Source: ${dir ? dir + '/' : ''}${filename}\n\n`;
|
|
26
|
+
return {
|
|
27
|
+
output: `${header}${importSection}import { test, expect } from 'vitest';\n\ntest('${itDescription}', async () => {\n${snippet.split('\n').map(line => ' ' + line).join('\n')}\n});`,
|
|
28
|
+
filepath: `${outputDir}/${testName}.test.ts`
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.builtInConfigs = {
|
|
33
|
+
jest: {
|
|
34
|
+
pattern: 'src/**/*.{ts,js,tsx,jsx}',
|
|
35
|
+
mapper: createJestMapper()
|
|
36
|
+
},
|
|
37
|
+
vitest: {
|
|
38
|
+
pattern: 'src/**/*.{ts,js,tsx,jsx}',
|
|
39
|
+
mapper: createVitestMapper()
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=builtins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtins.js","sourceRoot":"","sources":["../src/builtins.ts"],"names":[],"mappings":";;;AAEA,4CAcC;AAED,gDAcC;AA9BD,SAAgB,gBAAgB;IAC9B,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC1D,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,4BAA4B,EAAE,EAAE,CAAC,CAAC;QACpE,MAAM,SAAS,GAAG,GAAG,IAAI,GAAG,CAAC;QAC7B,MAAM,aAAa,GAAG,WAAW,IAAI,cAAc,CAAC;QAEpD,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5E,MAAM,MAAM,GAAG,uDAAuD,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,MAAM,CAAC;QAE5G,OAAO;YACL,MAAM,EAAE,GAAG,MAAM,GAAG,aAAa,aAAa,QAAQ,qBAAqB,aAAa,qBAAqB,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC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/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const url_1 = require("url");
|
|
9
|
+
const generator_js_1 = require("./generator.js");
|
|
10
|
+
const builtins_js_1 = require("./builtins.js");
|
|
11
|
+
async function loadConfig(configPath) {
|
|
12
|
+
// Check for built-in configs first
|
|
13
|
+
if (builtins_js_1.builtInConfigs[configPath]) {
|
|
14
|
+
return builtins_js_1.builtInConfigs[configPath];
|
|
15
|
+
}
|
|
16
|
+
const resolvedPath = path_1.default.resolve(configPath);
|
|
17
|
+
const fileUrl = (0, url_1.pathToFileURL)(resolvedPath).href;
|
|
18
|
+
const module = await import(fileUrl);
|
|
19
|
+
return module.default || module;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* CLI entry point for example-test-gen
|
|
23
|
+
*
|
|
24
|
+
* @example CLI01_help_flag_shows_usage_info
|
|
25
|
+
* ```ts
|
|
26
|
+
* import { runCli, readFile } from './test/helpers/cli.js';
|
|
27
|
+
* expect(runCli('--help')).toContain(readFile('outputs/help.txt'));
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example CLI01_version_flag_shows_package_version
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { runCli, getPackageVersion } from './test/helpers/cli.js';
|
|
33
|
+
* const output = runCli('--version').trim();
|
|
34
|
+
* expect(output).toBe(getPackageVersion());
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example CLI02_builtin_config_jest_generates_jest_tests
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { runCliWith, cleanDir, assertExists } from './test/helpers/cli.js';
|
|
40
|
+
* cleanDir('generated-tests');
|
|
41
|
+
* runCliWith({ config: 'jest' });
|
|
42
|
+
* assertExists('cli.test.js');
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @example CLI02_builtin_config_vitest_generates_vitest_tests
|
|
46
|
+
* ```ts
|
|
47
|
+
* import { runCliWith, cleanDir, assertExists } from './test/helpers/cli.js';
|
|
48
|
+
* cleanDir('tests');
|
|
49
|
+
* runCliWith({ config: 'vitest' });
|
|
50
|
+
* assertExists('tests/cli.test.ts');
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @example CLI03_custom_config_path_loads_user_defined_config
|
|
54
|
+
* ```ts
|
|
55
|
+
* import { runCliWith, cleanDir, assertExists } from './test/helpers/cli.js';
|
|
56
|
+
* cleanDir('custom-output');
|
|
57
|
+
* runCliWith({ config: 'test/fixtures/config/custom.mjs' });
|
|
58
|
+
* assertExists('custom-output/cli.test.js');
|
|
59
|
+
* cleanDir('custom-output');
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @example CLI04_missing_config_shows_clear_error
|
|
63
|
+
* ```ts
|
|
64
|
+
* import { runCli, expectError } from './test/helpers/cli.js';
|
|
65
|
+
* const err = expectError(() => runCli('--config=nonexistent-config.mjs'));
|
|
66
|
+
* expect(err.message).toContain('Error');
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @example CLI04_invalid_config_path_shows_error
|
|
70
|
+
* ```ts
|
|
71
|
+
* import { runCli, expectError } from './test/helpers/cli.js';
|
|
72
|
+
* const err = expectError(() => runCli('--config=/path/that/does/not/exist.mjs'));
|
|
73
|
+
* expect(err.message).toMatch(/Error|Cannot find module/);
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @example CLI05_files_flag_overrides_config_pattern
|
|
77
|
+
* ```ts
|
|
78
|
+
* import { runCliWith, cleanDir, assertExists } from './test/helpers/cli.js';
|
|
79
|
+
* cleanDir('tests');
|
|
80
|
+
* runCliWith({ config: 'vitest', files: 'src/cli.ts' });
|
|
81
|
+
* assertExists('tests/cli.test.ts');
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @example CLI05_files_flag_supports_multiple_patterns
|
|
85
|
+
* ```ts
|
|
86
|
+
* import { runCliWith, cleanDir, assertExists } from './test/helpers/cli.js';
|
|
87
|
+
* cleanDir('tests');
|
|
88
|
+
* runCliWith({ config: 'vitest', files: 'src/cli.ts,src/index.ts' });
|
|
89
|
+
* assertExists('tests/cli.test.ts');
|
|
90
|
+
* assertExists('tests/index.test.ts');
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @example CLI06_outDir_flag_overrides_default_output_directory
|
|
94
|
+
* ```ts
|
|
95
|
+
* import { runCliWith, cleanDir, assertExists } from '../test/helpers/cli.js';
|
|
96
|
+
* cleanDir('my-custom-tests');
|
|
97
|
+
* runCliWith({ config: 'vitest', outDir: 'my-custom-tests' });
|
|
98
|
+
* assertExists('my-custom-tests/cli.test.ts');
|
|
99
|
+
* cleanDir('my-custom-tests');
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
async function main() {
|
|
103
|
+
const args = process.argv.slice(2);
|
|
104
|
+
const configFlag = args.find((arg) => arg.startsWith('--config='));
|
|
105
|
+
const configPath = configFlag ? configFlag.replace('--config=', '') : 'example-test-gen.config.mjs';
|
|
106
|
+
try {
|
|
107
|
+
const { mapper, pattern } = await loadConfig(configPath);
|
|
108
|
+
await (0, generator_js_1.generate)({ pattern, mapper });
|
|
109
|
+
console.log('Test files generated successfully');
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
console.error('Error:', err.message);
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
main();
|
|
117
|
+
//# source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MAAM,EAAE,CAAC,CAAC;QACpC,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;IACnD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAG,GAAa,CAAC,OAAO,CAAC,CAAC;QAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":""}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SnippetInfo } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Extracts @example code snippets from a file
|
|
4
|
+
* @example extracts snippets correctly
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { extractSnippets } from './extractor.ts';
|
|
7
|
+
*
|
|
8
|
+
* // Interestingly, the extractor.ts path we provide to extractSnippets
|
|
9
|
+
* // is different from the path we use in the import statement.
|
|
10
|
+
* // This is because extractSnippets expects a project-relative path,
|
|
11
|
+
* // while the import statement depends on the test file's location
|
|
12
|
+
* // relative to this file.
|
|
13
|
+
*
|
|
14
|
+
* const snippets = await extractSnippets('./src/extractor.ts', process.cwd());
|
|
15
|
+
* expect(snippets[0].description).toBe('extracts snippets correctly');
|
|
16
|
+
* expect(snippets[0].filename).toBe('extractor.ts');
|
|
17
|
+
* expect(snippets[0].dir).toBe('src');
|
|
18
|
+
*
|
|
19
|
+
* // FOOBARBAZBAT <-- should be in the snippet, since I wrote it here.
|
|
20
|
+
* expect(snippets[0].snippet).toContain('FOOBARBAZBAT');
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function extractSnippets(filePath: string, cwd: string): Promise<SnippetInfo[]>;
|
|
24
|
+
export declare function findFiles(patterns: string | string[], cwd: string): AsyncGenerator<string>;
|
|
25
|
+
//# sourceMappingURL=extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractor.d.ts","sourceRoot":"","sources":["../src/extractor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAIzC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,WAAW,EAAE,CAAC,CAoCxB;AAED,wBAAuB,SAAS,CAC9B,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,EAC3B,GAAG,EAAE,MAAM,GACV,cAAc,CAAC,MAAM,CAAC,CAMxB"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.extractSnippets = extractSnippets;
|
|
7
|
+
exports.findFiles = findFiles;
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const EXAMPLE_REGEX = /@example(?:\s+([^\n`]+))?\s*\n?\s*(?:\*\s*)?```[a-z]*\n?([\s\S]*?)```/g;
|
|
11
|
+
/**
|
|
12
|
+
* Extracts @example code snippets from a file
|
|
13
|
+
* @example extracts snippets correctly
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { extractSnippets } from './extractor.ts';
|
|
16
|
+
*
|
|
17
|
+
* // Interestingly, the extractor.ts path we provide to extractSnippets
|
|
18
|
+
* // is different from the path we use in the import statement.
|
|
19
|
+
* // This is because extractSnippets expects a project-relative path,
|
|
20
|
+
* // while the import statement depends on the test file's location
|
|
21
|
+
* // relative to this file.
|
|
22
|
+
*
|
|
23
|
+
* const snippets = await extractSnippets('./src/extractor.ts', process.cwd());
|
|
24
|
+
* expect(snippets[0].description).toBe('extracts snippets correctly');
|
|
25
|
+
* expect(snippets[0].filename).toBe('extractor.ts');
|
|
26
|
+
* expect(snippets[0].dir).toBe('src');
|
|
27
|
+
*
|
|
28
|
+
* // FOOBARBAZBAT <-- should be in the snippet, since I wrote it here.
|
|
29
|
+
* expect(snippets[0].snippet).toContain('FOOBARBAZBAT');
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
async function extractSnippets(filePath, cwd) {
|
|
33
|
+
const content = await fs_1.promises.readFile(filePath, 'utf-8');
|
|
34
|
+
const dir = path_1.default.dirname(path_1.default.relative(cwd, filePath));
|
|
35
|
+
const filename = path_1.default.basename(filePath);
|
|
36
|
+
const snippets = [];
|
|
37
|
+
let match;
|
|
38
|
+
while ((match = EXAMPLE_REGEX.exec(content)) !== null) {
|
|
39
|
+
const description = match[1]?.trim() ?? null;
|
|
40
|
+
const rawSnippet = match[2].trim();
|
|
41
|
+
// Strip JSDoc comment prefixes from each line
|
|
42
|
+
const cleanedSnippet = rawSnippet
|
|
43
|
+
.split('\n')
|
|
44
|
+
.map(line => line.replace(/^\s*\*\s?/, ''))
|
|
45
|
+
.join('\n');
|
|
46
|
+
// Separate import statements from the rest of the snippet
|
|
47
|
+
const lines = cleanedSnippet.split('\n');
|
|
48
|
+
const imports = [];
|
|
49
|
+
const codeLines = [];
|
|
50
|
+
for (const line of lines) {
|
|
51
|
+
const trimmed = line.trim();
|
|
52
|
+
if (trimmed.startsWith('import ') || trimmed.startsWith('require(')) {
|
|
53
|
+
imports.push(line);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
codeLines.push(line);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const snippet = codeLines.join('\n').trim();
|
|
60
|
+
snippets.push({ imports, snippet, description, dir, filename });
|
|
61
|
+
}
|
|
62
|
+
return snippets;
|
|
63
|
+
}
|
|
64
|
+
async function* findFiles(patterns, cwd) {
|
|
65
|
+
const fg = await import('fast-glob');
|
|
66
|
+
const files = await fg.default(patterns, { cwd, absolute: true });
|
|
67
|
+
for (const file of files) {
|
|
68
|
+
yield file;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractor.js","sourceRoot":"","sources":["../src/extractor.ts"],"names":[],"mappings":";;;;;AA2BA,0CAuCC;AAED,8BASC;AA7ED,2BAAoC;AACpC,gDAAwB;AAGxB,MAAM,aAAa,GAAG,wEAAwE,CAAC;AAE/F;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,KAAK,UAAU,eAAe,CACnC,QAAgB,EAChB,GAAW;IAEX,MAAM,OAAO,GAAG,MAAM,aAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACrD,MAAM,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,cAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,cAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAEzC,MAAM,QAAQ,GAAkB,EAAE,CAAC;IACnC,IAAI,KAA6B,CAAC;IAElC,OAAO,CAAC,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACtD,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC;QAC7C,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACnC,8CAA8C;QAC9C,MAAM,cAAc,GAAG,UAAU;aAC9B,KAAK,CAAC,IAAI,CAAC;aACX,G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0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAgB,MAAM,YAAY,CAAC;AAG3D,wBAAsB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBtE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generate = generate;
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const extractor_js_1 = require("./extractor.js");
|
|
10
|
+
async function generate(options) {
|
|
11
|
+
const { pattern, mapper, cwd = process.cwd() } = options;
|
|
12
|
+
for await (const filePath of (0, extractor_js_1.findFiles)(pattern, cwd)) {
|
|
13
|
+
const snippets = await (0, extractor_js_1.extractSnippets)(filePath, cwd);
|
|
14
|
+
for (const snippetInfo of snippets) {
|
|
15
|
+
const result = await mapper(snippetInfo);
|
|
16
|
+
if (!result)
|
|
17
|
+
continue;
|
|
18
|
+
const { output, filepath: relativeOutputPath } = result;
|
|
19
|
+
const absoluteOutputPath = path_1.default.resolve(cwd, relativeOutputPath);
|
|
20
|
+
const outputDir = path_1.default.dirname(absoluteOutputPath);
|
|
21
|
+
await fs_1.promises.mkdir(outputDir, { recursive: true });
|
|
22
|
+
await fs_1.promises.writeFile(absoluteOutputPath, output, 'utf-8');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":";;;;;AAKA,4BAmBC;AAxBD,2BAAoC;AACpC,gDAAwB;AAExB,iDAA4D;AAErD,KAAK,UAAU,QAAQ,CAAC,OAAwB;IACrD,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IAEzD,IAAI,KAAK,EAAE,MAAM,QAAQ,IAAI,IAAA,wBAAS,EAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;QACrD,MAAM,QAAQ,GAAG,MAAM,IAAA,8BAAe,EAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAEtD,KAAK,MAAM,WAAW,IAAI,QAAQ,EAAE,CAAC;YACnC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC;YAEzC,IAAI,CAAC,MAAM;gBAAE,SAAS;YAEtB,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,GAAG,MAAM,CAAC;YACxD,MAAM,kBAAkB,GAAG,cAAI,CAAC,OAAO,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;YACjE,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;YAEnD,MAAM,aAAE,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC/C,MAAM,aAAE,CAAC,SAAS,CAAC,kBAAkB,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MapperFunction } from './types.js';
|
|
2
|
+
export { generate } from './generator.js';
|
|
3
|
+
export { GenerateOptions, MapperFunction, MapperResult, SnippetInfo } from './types.js';
|
|
4
|
+
export { createJestMapper, createVitestMapper, builtInConfigs } from './builtins.js';
|
|
5
|
+
export declare function generateTests(pattern: string | string[], mapper: MapperFunction, cwd?: string): Promise<void>;
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,cAAc,EAAE,MAAM,YAAY,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAErF,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAC1B,MAAM,EAAE,cAAc,EACtB,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAEf"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.builtInConfigs = exports.createVitestMapper = exports.createJestMapper = exports.generate = void 0;
|
|
4
|
+
exports.generateTests = generateTests;
|
|
5
|
+
const generator_js_1 = require("./generator.js");
|
|
6
|
+
var generator_js_2 = require("./generator.js");
|
|
7
|
+
Object.defineProperty(exports, "generate", { enumerable: true, get: function () { return generator_js_2.generate; } });
|
|
8
|
+
var builtins_js_1 = require("./builtins.js");
|
|
9
|
+
Object.defineProperty(exports, "createJestMapper", { enumerable: true, get: function () { return builtins_js_1.createJestMapper; } });
|
|
10
|
+
Object.defineProperty(exports, "createVitestMapper", { enumerable: true, get: function () { return builtins_js_1.createVitestMapper; } });
|
|
11
|
+
Object.defineProperty(exports, "builtInConfigs", { enumerable: true, get: function () { return builtins_js_1.builtInConfigs; } });
|
|
12
|
+
async function generateTests(pattern, mapper, cwd) {
|
|
13
|
+
return (0, generator_js_1.generate)({ pattern, mapper, cwd });
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAOA,sCAMC;AAbD,iDAA0C;AAG1C,+CAA0C;AAAjC,wGAAA,QAAQ,OAAA;AAEjB,6CAAqF;AAA5E,+GAAA,gBAAgB,OAAA;AAAE,iHAAA,kBAAkB,OAAA;AAAE,6GAAA,cAAc,OAAA;AAEtD,KAAK,UAAU,aAAa,CACjC,OAA0B,EAC1B,MAAsB,EACtB,GAAY;IAEZ,OAAO,IAAA,uBAAQ,EAAC,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;AAC5C,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface SnippetInfo {
|
|
2
|
+
imports: string[];
|
|
3
|
+
snippet: string;
|
|
4
|
+
description: string | null;
|
|
5
|
+
dir: string;
|
|
6
|
+
filename: string;
|
|
7
|
+
}
|
|
8
|
+
export interface MapperResult {
|
|
9
|
+
output: string;
|
|
10
|
+
filepath: string;
|
|
11
|
+
}
|
|
12
|
+
export type MapperFunction = (info: SnippetInfo) => MapperResult | null | Promise<MapperResult | null>;
|
|
13
|
+
export interface GenerateOptions {
|
|
14
|
+
pattern: string | string[];
|
|
15
|
+
mapper: MapperFunction;
|
|
16
|
+
cwd?: string;
|
|
17
|
+
/** Output directory for generated tests (default: 'tests') */
|
|
18
|
+
outDir?: string;
|
|
19
|
+
}
|
|
20
|
+
/** @deprecated Use GenerateOptions instead - maintained for backwards compatibility */
|
|
21
|
+
export type Config = GenerateOptions;
|
|
22
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,WAAW,KAAK,YAAY,GAAG,IAAI,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;AAEvG,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B,MAAM,EAAE,cAAc,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,uFAAuF;AACvF,MAAM,MAAM,MAAM,GAAG,eAAe,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "example-test-gen",
|
|
3
|
+
"version": "1.0.0-prerelease-2026-03-31",
|
|
4
|
+
"description": "Generate test files from @example snippets in your code",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"example-test-gen": "dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"prepare": "npm run build",
|
|
13
|
+
"pretest": "npx example-test-gen --config=vitest",
|
|
14
|
+
"test": "vitest run"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"test",
|
|
18
|
+
"example",
|
|
19
|
+
"jsdoc",
|
|
20
|
+
"generate",
|
|
21
|
+
"snippet"
|
|
22
|
+
],
|
|
23
|
+
"files": [
|
|
24
|
+
"dist/"
|
|
25
|
+
],
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"fast-glob": "^3.3.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^20.0.0",
|
|
31
|
+
"jest": "^29.7.0",
|
|
32
|
+
"typescript": "^5.3.0",
|
|
33
|
+
"vitest": "^1.0.0"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=18.0.0"
|
|
37
|
+
}
|
|
38
|
+
}
|