Skip to content

Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.

test(desktop): initialize standalone network probe with a CommonJS entry

Leggett976e306f6a50
diff --git a/apps/desktop/e2e/desktop-network.spec.ts b/apps/desktop/e2e/desktop-network.spec.ts
index d539da39..30fa94ca 100644
--- a/apps/desktop/e2e/desktop-network.spec.ts
+++ b/apps/desktop/e2e/desktop-network.spec.ts
@@ -39,13 +39,19 @@ test('@package-smoke Desktop 网络在 Socket QoS 抛出 EINVAL 时仍可请求
await new Promise<void>(resolve => server.listen(0, '127.0.0.1', resolve));
try {
const resultPath = join(userData, 'network-test-result.json');
- const env: NodeJS.ProcessEnv = { ...process.env, OPENCREATOR_DESKTOP_NETWORK_TEST_RESULT: resultPath };
+ const electronLogPath = join(userData, 'electron.log');
+ const env: NodeJS.ProcessEnv = {
+ ...process.env,
+ OPENCREATOR_DESKTOP_NETWORK_TEST_RESULT: resultPath,
+ ELECTRON_ENABLE_LOGGING: '1',
+ ELECTRON_LOG_FILE: electronLogPath
+ };
delete env.ELECTRON_RUN_AS_NODE;
let processFailure: unknown;
let stderr = '';
try {
const result = await run(electronExecutable, [
- resolve(e2eDir, 'fixtures/desktop-network.mjs'),
+ resolve(e2eDir, 'fixtures/desktop-network.cjs'),
pathToFileURL(resolve(e2eDir, '../dist/main/desktop-network.js')).href,
`http://127.0.0.1:${(server.address() as AddressInfo).port}`,
userData
@@ -55,6 +61,9 @@ test('@package-smoke Desktop 网络在 Socket QoS 抛出 EINVAL 时仍可请求
// GUI executables do not reliably expose console output on Windows.
const report = existsSync(resultPath) ? readFileSync(resultPath, 'utf8') : 'No network test result file';
await testInfo.attach('desktop-network-result', { body: report, contentType: 'application/json' });
+ if (existsSync(electronLogPath)) {
+ await testInfo.attach('desktop-network-electron-log', { path: electronLogPath, contentType: 'text/plain' });
+ }
expect(processFailure, report).toBeUndefined();
expect(existsSync(resultPath), report).toBe(true);
expect(JSON.parse(report)).toMatchObject({ ok: true, phase: 'complete' });
diff --git a/apps/desktop/e2e/fixtures/desktop-network.mjs b/apps/desktop/e2e/fixtures/desktop-network.cjs
similarity index 90%
rename from apps/desktop/e2e/fixtures/desktop-network.mjs
rename to apps/desktop/e2e/fixtures/desktop-network.cjs
index 0b26713d..32dd8c61 100644
--- a/apps/desktop/e2e/fixtures/desktop-network.mjs
+++ b/apps/desktop/e2e/fixtures/desktop-network.cjs
@@ -1,11 +1,13 @@
-import assert from 'node:assert/strict';
-import { writeFileSync } from 'node:fs';
-import { Socket } from 'node:net';
-import { app } from 'electron';
+const assert = require('node:assert/strict');
+const { writeFileSync } = require('node:fs');
+const { Socket } = require('node:net');
+const { app } = require('electron');
let phase = 'initialization';
const report = result => writeFileSync(process.env.OPENCREATOR_DESKTOP_NETWORK_TEST_RESULT, `${JSON.stringify({ phase, ...result }, null, 2)}\n`);
+report({ ok: false, pending: true });
+
void (async () => {
app.setPath('userData', process.argv[4]);
Socket.prototype.setTypeOfService = () => {