@aloma.io/integration-sdk 3.8.66 → 3.8.68
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 +60 -0
- package/build/builder/runtime-context.mjs +2 -2
- package/build/cli.mjs +0 -0
- package/build/controller/index.d.mts +3 -2
- package/build/controller/index.mjs +4 -3
- package/build/internal/dispatcher/index.d.mts +1 -4
- package/build/internal/dispatcher/index.mjs +3 -2
- package/build/testing/fake-aloma.d.mts +87 -0
- package/build/testing/fake-aloma.mjs +248 -0
- package/build/testing/harness.d.mts +51 -0
- package/build/testing/harness.mjs +139 -0
- package/build/testing/index.d.mts +15 -0
- package/build/testing/index.mjs +13 -0
- package/build/testing/keys.d.mts +9 -0
- package/build/testing/keys.mjs +15 -0
- package/build/testing/network-guard.d.mts +3 -0
- package/build/testing/network-guard.mjs +49 -0
- package/build/testing/runtime-connector.d.mts +11 -0
- package/build/testing/runtime-connector.mjs +38 -0
- package/build/testing/vendor-mock.d.mts +59 -0
- package/build/testing/vendor-mock.mjs +121 -0
- package/package.json +8 -4
- package/src/builder/runtime-context.mts +2 -2
- package/src/controller/index.mts +4 -3
- package/src/internal/dispatcher/index.mts +3 -2
- package/src/testing/fake-aloma.mts +306 -0
- package/src/testing/harness.mts +172 -0
- package/src/testing/index.mts +15 -0
- package/src/testing/keys.mts +19 -0
- package/src/testing/network-guard.mts +57 -0
- package/src/testing/runtime-connector.mts +50 -0
- package/src/testing/vendor-mock.mts +166 -0
- package/test/MUTATION-entry.md +21 -0
- package/test/MUTATION.md +43 -0
- package/test/dispatcher-ctx-forwarding.test.mjs +161 -0
- package/test/harness-connector-smoke.test.mjs +72 -0
- package/test/harness.test.mjs +375 -0
- package/test/openapi-to-connector.test.mts +25 -7
- package/test/scenarios.test.mts +15 -7
- package/tools/mutation-run-entry.mjs +52 -0
- package/tools/mutation-run.mjs +120 -0
- package/tools/run-tests.mjs +64 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// `yarn test`: runs every test file in test/.
|
|
2
|
+
//
|
|
3
|
+
// Two kinds of test file live in test/:
|
|
4
|
+
// - mocha files (describe/it): files that import from 'mocha'. They run together in ONE mocha process.
|
|
5
|
+
// - standalone scripts (their own tiny test() helper, finish with process.exit): every other test/*.test.mjs, plus
|
|
6
|
+
// test/verify-scenarios.mjs. Each runs in its own node process, because process.exit() inside a mocha process
|
|
7
|
+
// ends the whole run while mocha is still loading files, so none of the describe/it tests would run.
|
|
8
|
+
// A new test file is picked up by name (test/*.test.mjs|mts). Exit code is non-zero if anything fails.
|
|
9
|
+
import {createRequire} from 'node:module';
|
|
10
|
+
import {spawnSync} from 'node:child_process';
|
|
11
|
+
import fs from 'node:fs';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
import {fileURLToPath} from 'node:url';
|
|
14
|
+
|
|
15
|
+
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
16
|
+
const testDir = path.join(root, 'test');
|
|
17
|
+
|
|
18
|
+
const files = fs.readdirSync(testDir).filter((f) => /\.test\.m[jt]s$/.test(f)).sort();
|
|
19
|
+
const isMocha = (f) => /from ['"]mocha['"]/.test(fs.readFileSync(path.join(testDir, f), 'utf8'));
|
|
20
|
+
// .mts test files are transpiled (type-stripped) to sibling .mjs files and run by plain mocha. The ts-node/esm loader
|
|
21
|
+
// cannot be used: it fails on Node 18 (ERR_UNKNOWN_FILE_EXTENSION) and Node 20 (ERR_INTERNAL_ASSERTION). The sibling
|
|
22
|
+
// location keeps relative imports and import.meta.url paths identical to the source file.
|
|
23
|
+
const require = createRequire(import.meta.url);
|
|
24
|
+
const ts = require('typescript');
|
|
25
|
+
const generated = [];
|
|
26
|
+
const compile = (f) => {
|
|
27
|
+
if (!f.endsWith('.mts')) return path.join('test', f);
|
|
28
|
+
const out = path.join('test', `.compiled-${f.replace(/\.mts$/, '.mjs')}`);
|
|
29
|
+
const src = fs.readFileSync(path.join(testDir, f), 'utf8');
|
|
30
|
+
const js = ts.transpileModule(src, {
|
|
31
|
+
compilerOptions: {module: ts.ModuleKind.ESNext, target: ts.ScriptTarget.ES2022},
|
|
32
|
+
fileName: f,
|
|
33
|
+
}).outputText;
|
|
34
|
+
fs.writeFileSync(path.join(root, out), js);
|
|
35
|
+
generated.push(path.join(root, out));
|
|
36
|
+
return out;
|
|
37
|
+
};
|
|
38
|
+
const mochaFiles = files.filter(isMocha).map(compile);
|
|
39
|
+
const scripts = files.filter((f) => !isMocha(f)).map((f) => path.join('test', f));
|
|
40
|
+
scripts.push(path.join('test', 'verify-scenarios.mjs'));
|
|
41
|
+
|
|
42
|
+
const failures = [];
|
|
43
|
+
const run = (label, cmd, args) => {
|
|
44
|
+
console.log(`\n=== ${label}`);
|
|
45
|
+
const r = spawnSync(cmd, args, {cwd: root, stdio: 'inherit'});
|
|
46
|
+
if (r.status !== 0) failures.push(label);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
if (mochaFiles.length) {
|
|
50
|
+
run(`mocha (${mochaFiles.length} files)`, process.execPath, [
|
|
51
|
+
path.join(root, 'node_modules/mocha/bin/_mocha'),
|
|
52
|
+
'--exit',
|
|
53
|
+
...mochaFiles,
|
|
54
|
+
]);
|
|
55
|
+
}
|
|
56
|
+
for (const s of scripts) run(s, process.execPath, [s]);
|
|
57
|
+
|
|
58
|
+
for (const g of generated) fs.rmSync(g, {force: true});
|
|
59
|
+
|
|
60
|
+
console.log(`\n${mochaFiles.length} mocha files, ${scripts.length} standalone scripts, ${failures.length} failed`);
|
|
61
|
+
if (failures.length) {
|
|
62
|
+
console.log(`FAILED: ${failures.join(', ')}`);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|