Skip to content

Commit 79915be

Browse files
committed
adjustments
1 parent afb7393 commit 79915be

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

test/pure-ts-adapters.test.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ const { describe, it, before, after } = require('mocha');
22
const assert = require('node:assert');
33
const fs = require('node:fs');
44
const path = require('node:path');
5-
const {
6-
runCommand,
5+
const {
6+
runCommand,
77
runCommandWithSignal,
88
runCommandWithFileChange,
9-
setupTestAdapter,
9+
setupTestAdapter,
1010
cleanupTestAdapter,
1111
validateIoPackageJson,
1212
validatePackageJson,
@@ -62,9 +62,8 @@ describe('dev-server integration tests - Pure TypeScript', function () {
6262

6363
// Verify the build scripts have been removed
6464
assert.ok(packageJson.scripts.check?.includes("--noEmit"), 'check script should use --noEmit for type checking only');
65-
assert.ok(!packageJson.scripts?.['build:ts'], 'build:ts script should not exist');
65+
assert.ok(packageJson.scripts.build?.includes("--noEmit"), 'build script should use --noEmit for type checking only');
6666
assert.ok(!packageJson.scripts?.prebuild, 'prebuild script should not exist');
67-
assert.ok(!packageJson.scripts?.build, 'build script should not exist');
6867
});
6968

7069
it('should have TypeScript source file but no dist directory', () => {

test/test-utils.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ function runCommand(command, args, options = {}) {
3939
proc.on('close', (code) => {
4040
if (rejectedOrResolved) return;
4141
if (timeoutId) clearTimeout(timeoutId);
42+
console.log(`Process exited with code ${code}`);
4243
if (code === 0 || code === 255) {
4344
setTimeout(() => resolve({ stdout, stderr, code }), 5000);
4445
} else {
@@ -116,12 +117,12 @@ function runCommandWithTimeout(command, args, options = {}) {
116117
if (options.verbose) {
117118
console.log('STDOUT:', str.trim());
118119
}
119-
120+
120121
// Call custom stdout handler if provided
121122
if (options.onStdout) {
122123
options.onStdout(str, shutDown);
123124
}
124-
125+
125126
// Default behavior: shutdown on final message
126127
if (!options.onStdout && options.finalMessage && str.match(options.finalMessage) && !closed && !resolvedOrRejected) {
127128
console.log('Final message detected, shutting down...');
@@ -197,8 +198,9 @@ async function createTestAdapter(configFile, targetDir) {
197198
`--replay=${configPath}`,
198199
`--target=${targetDir}`,
199200
'--noInstall', // Skip npm install to speed up creation
200-
'--non-interactive' // Prevent interactive prompts
201+
'--nonInteractive' // Run in non-interactive mode to fill in missing config details
201202
], {
203+
verbose:true,
202204
cwd: targetDir,
203205
timeout: 180000, // 3 minutes
204206
env: { ...process.env, NODE_TLS_REJECT_UNAUTHORIZED: '0' } // Handle certificate issues in test environment
@@ -251,7 +253,7 @@ async function setupTestAdapter(config) {
251253

252254
// Install dependencies
253255
await installAdapterDependencies(adapterName, adapterDir);
254-
256+
255257
console.log(`${adapterName} test adapter prepared successfully`);
256258
}
257259

@@ -261,7 +263,7 @@ async function setupTestAdapter(config) {
261263
async function applyTypeScriptPatches(adapterDir) {
262264
const mainTsPath = path.join(adapterDir, 'src', 'main.ts');
263265
let mainTsContent = fs.readFileSync(mainTsPath, 'utf8');
264-
266+
265267
// Patch variable declarations for TypeScript compliance
266268
mainTsContent = mainTsContent.replace(
267269
'let result = await this.checkPasswordAsync("admin", "iobroker");',
@@ -275,7 +277,7 @@ async function applyTypeScriptPatches(adapterDir) {
275277
'this.log.info("check group user admin group admin: " + result);',
276278
'this.log.info("check group user admin group admin: " + groupResult);',
277279
);
278-
280+
279281
fs.writeFileSync(mainTsPath, mainTsContent, 'utf8');
280282
console.log(`Patched ${mainTsPath} for TypeScript compliance`);
281283
}
@@ -315,7 +317,7 @@ function cleanupTestAdapter(adapterName, adapterDir) {
315317
function validateIoPackageJson(adapterDir, expectedName, shouldHaveTypescript = false) {
316318
const ioPackagePath = path.join(adapterDir, 'io-package.json');
317319
const assert = require('node:assert');
318-
320+
319321
assert.ok(fs.existsSync(ioPackagePath), 'io-package.json not found');
320322

321323
const ioPackage = JSON.parse(fs.readFileSync(ioPackagePath, 'utf8'));
@@ -329,18 +331,18 @@ function validateIoPackageJson(adapterDir, expectedName, shouldHaveTypescript =
329331
}
330332

331333
/**
332-
* Common assertions for package.json validation
334+
* Common assertions for package.json validation
333335
*/
334336
function validatePackageJson(adapterDir) {
335337
const packagePath = path.join(adapterDir, 'package.json');
336338
const assert = require('node:assert');
337-
339+
338340
assert.ok(fs.existsSync(packagePath), 'package.json not found');
339341

340342
const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
341343
assert.ok(packageJson.name, 'package.json missing name');
342344
assert.ok(packageJson.version, 'package.json missing version');
343-
345+
344346
return packageJson;
345347
}
346348

@@ -350,7 +352,7 @@ function validatePackageJson(adapterDir) {
350352
function validateTypeScriptConfig(adapterDir) {
351353
const tsconfigPath = path.join(adapterDir, 'tsconfig.json');
352354
const assert = require('node:assert');
353-
355+
354356
assert.ok(fs.existsSync(tsconfigPath), 'tsconfig.json not found for TypeScript adapter');
355357
}
356358

@@ -462,7 +464,7 @@ function runCommandWithFileChange(command, args, options = {}) {
462464
if (!fileChanged && options.initialMessage && str.match(options.initialMessage)) {
463465
console.log('Initial message detected, triggering file change...');
464466
fileChanged = true;
465-
467+
466468
// Wait a bit then trigger file change
467469
setTimeout(() => {
468470
if (options.fileToChange) {
@@ -477,13 +479,13 @@ function runCommandWithFileChange(command, args, options = {}) {
477479
}
478480
}, 5000);
479481
}
480-
482+
481483
// Detect restart and wait for it to complete
482484
if (fileChanged && !restartDetected && str.match(/restarting|restart/i)) {
483485
console.log('Restart detected...');
484486
restartDetected = true;
485487
}
486-
488+
487489
// After restart, wait for final message
488490
if (restartDetected && options.finalMessage && str.match(options.finalMessage)) {
489491
console.log('Final message after restart detected, shutting down...');

0 commit comments

Comments
 (0)