test: rebuildable bundles, npm test entry point
- esbuild alias fixed in the session/sysinfo/sftp test commands (they could not build at all), .sftp-svc.mjs build documented, real connection-stability assertions - tests/build-bundles.cjs builds every bundle fresh; npm test runs the seven offline suites; esbuild pinned in devDependencies - remove the assertion-less .exact-inline.mjs; ignore/clean test temp dirs
This commit is contained in:
1 parent
24f7e7c52a
commit
cca4ba029a
12 files changed
+108
-92
No files matched your search
@@ -0,0 +1,43 @@
|
||||
/* Rebuild every esbuild bundle the tests load, so a test run can never exercise
|
||||
a stale bundle. `npm test` calls this first; run it standalone when you only
|
||||
want fresh bundles.
|
||||
|
||||
The aliases live here (and nowhere else) so every bundle resolves `electron`
|
||||
and `@shared` the same way. A bundle built without
|
||||
`--alias:@shared=./src/shared` does not even compile: pty.ts reaches
|
||||
@shared/theme through settingsStore.ts -> windowChrome.ts.
|
||||
|
||||
Usage: node tests/build-bundles.cjs */
|
||||
const path = require('node:path')
|
||||
const esbuild = require('esbuild')
|
||||
|
||||
const ROOT = path.join(__dirname, '..')
|
||||
|
||||
const BUNDLES = [
|
||||
// Real session layer: pty.ts also re-exports the ssh + sysinfo engines.
|
||||
{ entry: 'src/main/pty.ts', out: 'tests/.session-e2e.cjs', external: ['@lydell/node-pty', 'ssh2'] },
|
||||
// ESM (`.mjs`): tests/sftp-*.mjs load it with `await import()`.
|
||||
{ entry: 'src/main/sftp.ts', out: 'tests/.sftp-svc.mjs', format: 'esm', external: ['ssh2'] },
|
||||
{ entry: 'src/main/commands.ts', out: 'tests/.commands-store.cjs' },
|
||||
{ entry: 'src/main/settingsStore.ts', out: 'tests/.settings-store.cjs' },
|
||||
// zmodem.js stays bundled (NOT external) — the test drives a second in-process
|
||||
// Sentry from the same library.
|
||||
{ entry: 'src/main/zmodem.ts', out: 'tests/.zmodem-e2e.cjs', external: ['ssh2'] },
|
||||
// The smoke test imports the renderer engine (.ts), so it needs bundling too.
|
||||
{ entry: 'tests/hl-split-smoke.mjs', out: 'tests/.hl-split-smoke.cjs' }
|
||||
]
|
||||
|
||||
for (const { entry, out, format = 'cjs', external = [] } of BUNDLES) {
|
||||
esbuild.buildSync({
|
||||
absWorkingDir: ROOT,
|
||||
entryPoints: [path.join(ROOT, entry)],
|
||||
outfile: path.join(ROOT, out),
|
||||
bundle: true,
|
||||
platform: 'node',
|
||||
format,
|
||||
external,
|
||||
alias: { electron: './tests/electron-stub.cjs', '@shared': './src/shared' },
|
||||
logLevel: 'warning'
|
||||
})
|
||||
console.log(`built ${out}`)
|
||||
}
|
||||
Reference in new issue
Block a user