@iobroker/testing 5.0.4 → 5.1.1

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.
@@ -3,6 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeCommand = executeCommand;
4
4
  const child_process_1 = require("child_process");
5
5
  const isWindows = /^win/.test(process.platform);
6
+ /**
7
+ * Executes a command and returns the exit code and (if requested) the stdout
8
+ *
9
+ * @param command The command to execute
10
+ * @param argsOrOptions The command line arguments for the command
11
+ * @param options (optional) Some options for the command execution
12
+ */
6
13
  function executeCommand(command, argsOrOptions, options) {
7
14
  return new Promise(resolve => {
8
15
  let args;
@@ -34,8 +34,8 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.testAdapter = testAdapter;
37
- const os = __importStar(require("os"));
38
- const path = __importStar(require("path"));
37
+ const os = __importStar(require("node:os"));
38
+ const path = __importStar(require("node:path"));
39
39
  const adapterTools_1 = require("../../lib/adapterTools");
40
40
  const adapterSetup_1 = require("./lib/adapterSetup");
41
41
  const controllerSetup_1 = require("./lib/controllerSetup");
@@ -66,7 +66,7 @@ function testAdapter(adapterDir, options = {}) {
66
66
  const adapterSetup = new adapterSetup_1.AdapterSetup(adapterDir, testDir);
67
67
  // Installation happens in two steps:
68
68
  // First we need to set up JS Controller, so the databases etc. can be created
69
- // First we need to copy all files and execute an npm install
69
+ // First, we need to copy all files and execute a `npm install`
70
70
  await controllerSetup.prepareTestDir(options.controllerVersion);
71
71
  // Only then we can install the adapter, because some (including VIS) try to access
72
72
  // the databases if JS Controller is installed
@@ -178,7 +178,7 @@ function testAdapter(adapterDir, options = {}) {
178
178
  describe('User-defined tests', () => {
179
179
  // patch the global it() function so nobody can bypass the checks
180
180
  global.it = patchedIt;
181
- // a test suite is a special describe which sets up and tears down the test environment before and after ALL tests
181
+ // a test suite is a special `describe`, which sets up and tears down the test environment before and after ALL tests
182
182
  const suiteBody = (fn) => {
183
183
  isInSuite = true;
184
184
  before(resetDbAndStartHarness);
@@ -40,7 +40,7 @@ exports.AdapterSetup = void 0;
40
40
  // Add debug logging for tests
41
41
  const debug_1 = __importDefault(require("debug"));
42
42
  const fs_extra_1 = require("fs-extra");
43
- const path = __importStar(require("path"));
43
+ const path = __importStar(require("node:path"));
44
44
  const adapterTools_1 = require("../../../lib/adapterTools");
45
45
  const executeCommand_1 = require("../../../lib/executeCommand");
46
46
  const tools_1 = require("./tools");
@@ -40,8 +40,8 @@ exports.ControllerSetup = void 0;
40
40
  // Add debug logging for tests
41
41
  const debug_1 = __importDefault(require("debug"));
42
42
  const fs_extra_1 = require("fs-extra");
43
- const net_1 = require("net");
44
- const path = __importStar(require("path"));
43
+ const node_net_1 = require("node:net");
44
+ const path = __importStar(require("node:path"));
45
45
  const adapterTools_1 = require("../../../lib/adapterTools");
46
46
  const executeCommand_1 = require("../../../lib/executeCommand");
47
47
  const tools_1 = require("./tools");
@@ -125,7 +125,7 @@ class ControllerSetup {
125
125
  isJsControllerRunning() {
126
126
  debug('Testing if JS-Controller is running...');
127
127
  return new Promise(resolve => {
128
- const client = new net_1.Socket();
128
+ const client = new node_net_1.Socket();
129
129
  const timeout = setTimeout(() => {
130
130
  // Assume the connection failed after 1 s
131
131
  client.destroy();
@@ -1,4 +1,4 @@
1
- import EventEmitter from 'events';
1
+ import EventEmitter from 'node:events';
2
2
  export type ObjectsDB = Record<string, ioBroker.Object>;
3
3
  export type StatesDB = Record<string, ioBroker.State>;
4
4
  export interface DBConnection {
@@ -38,13 +38,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.DBConnection = void 0;
40
40
  const debug_1 = __importDefault(require("debug"));
41
- const events_1 = __importDefault(require("events"));
41
+ const node_events_1 = __importDefault(require("node:events"));
42
42
  const fs_extra_1 = require("fs-extra");
43
- const path = __importStar(require("path"));
43
+ const path = __importStar(require("node:path"));
44
44
  const tools_1 = require("./tools");
45
45
  const debug = (0, debug_1.default)('testing:integration:DBConnection');
46
46
  /** The DB connection capsules access to the states and objects DB */
47
- class DBConnection extends events_1.default {
47
+ class DBConnection extends node_events_1.default {
48
48
  /**
49
49
  * @param appName The branded name of "iobroker"
50
50
  * @param testDir The directory the integration tests are executed in
@@ -1,5 +1,5 @@
1
- import { type ChildProcess } from 'child_process';
2
- import { EventEmitter } from 'events';
1
+ import { type ChildProcess } from 'node:child_process';
2
+ import { EventEmitter } from 'node:events';
3
3
  import type { DBConnection } from './dbConnection';
4
4
  export interface TestHarness {
5
5
  on(event: 'objectChange', handler: ioBroker.ObjectChangeHandler): this;
@@ -39,10 +39,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.TestHarness = void 0;
40
40
  const async_1 = require("alcalzone-shared/async");
41
41
  const objects_1 = require("alcalzone-shared/objects");
42
- const child_process_1 = require("child_process");
42
+ const node_child_process_1 = require("node:child_process");
43
43
  const debug_1 = __importDefault(require("debug"));
44
- const events_1 = require("events");
45
- const path = __importStar(require("path"));
44
+ const node_events_1 = require("node:events");
45
+ const path = __importStar(require("node:path"));
46
46
  const adapterTools_1 = require("../../../lib/adapterTools");
47
47
  const tools_1 = require("./tools");
48
48
  const debug = (0, debug_1.default)('testing:integration:TestHarness');
@@ -52,7 +52,7 @@ const fromAdapterID = 'system.adapter.test.0';
52
52
  * The test harness capsules the execution of the JS-Controller and the adapter instance and monitors their status.
53
53
  * Use it in every test to start a fresh adapter instance
54
54
  */
55
- class TestHarness extends events_1.EventEmitter {
55
+ class TestHarness extends node_events_1.EventEmitter {
56
56
  /**
57
57
  * @param adapterDir The root directory of the adapter
58
58
  * @param testDir The directory the integration tests are executed in
@@ -164,7 +164,7 @@ class TestHarness extends events_1.EventEmitter {
164
164
  this._adapterExit = code != undefined ? code : signal;
165
165
  this.emit('failed', this._adapterExit);
166
166
  };
167
- this._adapterProcess = (0, child_process_1.spawn)(isWindows ? 'node.exe' : 'node', [mainFileRelative, '--console'], {
167
+ this._adapterProcess = (0, node_child_process_1.spawn)(isWindows ? 'node.exe' : 'node', [mainFileRelative, '--console'], {
168
168
  cwd: this.testAdapterDir,
169
169
  stdio: ['inherit', 'inherit', 'inherit'],
170
170
  env: { ...process.env, ...env },
@@ -38,7 +38,7 @@ exports.getTestDataDir = getTestDataDir;
38
38
  exports.getTestLogDir = getTestLogDir;
39
39
  exports.getTestDBDir = getTestDBDir;
40
40
  exports.getTestAdapterDir = getTestAdapterDir;
41
- const path = __importStar(require("path"));
41
+ const path = __importStar(require("node:path"));
42
42
  const adapterTools_1 = require("../../../lib/adapterTools");
43
43
  /**
44
44
  * Locates the directory where JS-Controller is installed for integration tests
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iobroker/testing",
3
- "version": "5.0.4",
3
+ "version": "5.1.1",
4
4
  "description": "Shared utilities for adapter and module testing in ioBroker",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -41,31 +41,31 @@
41
41
  "devDependencies": {
42
42
  "@alcalzone/release-script": "^3.8.0",
43
43
  "@alcalzone/release-script-plugin-license": "^3.7.0",
44
- "@iobroker/adapter-core": "^3.2.3",
45
- "@iobroker/eslint-config": "^2.0.1",
46
- "@iobroker/types": "^7.0.6",
47
- "@tsconfig/node16": "^16.1.3",
48
- "@types/chai": "^4.3.20",
49
- "@types/chai-as-promised": "^8.0.1",
50
- "@types/debug": "4.1.12",
44
+ "@iobroker/adapter-core": "^3.3.2",
45
+ "@iobroker/eslint-config": "^2.1.0",
46
+ "@iobroker/types": "^7.0.7",
47
+ "@tsconfig/node16": "^16.1.4",
48
+ "@types/debug": "^4.1.12",
51
49
  "@types/fs-extra": "^11.0.4",
52
- "@types/mocha": "^10.0.10",
53
- "@types/node": "^22.13.13",
54
- "@types/sinon": "^17.0.4",
55
- "@types/sinon-chai": "^3.2.12",
50
+ "@types/node": "^24.3.0",
56
51
  "rimraf": "^6.0.1",
57
52
  "source-map-support": "^0.5.21",
58
53
  "ts-node": "^10.9.2",
59
- "typescript": "~5.8.2"
54
+ "typescript": "~5.9.2"
60
55
  },
61
56
  "dependencies": {
57
+ "@types/chai": "^4.3.20",
58
+ "@types/chai-as-promised": "^7.1.8",
59
+ "@types/mocha": "^10.0.10",
60
+ "@types/sinon": "^17.0.4",
61
+ "@types/sinon-chai": "^3.2.12",
62
62
  "alcalzone-shared": "~5.0.0",
63
63
  "chai": "^4.5.0",
64
64
  "chai-as-promised": "^7.1.2",
65
- "debug": "^4.4.0",
66
- "fs-extra": "^11.3.0",
67
- "mocha": "^11.1.0",
68
- "sinon": "^19.0.4",
65
+ "debug": "^4.4.1",
66
+ "fs-extra": "^11.3.1",
67
+ "mocha": "^11.7.1",
68
+ "sinon": "^21.0.0",
69
69
  "sinon-chai": "^3.7.0"
70
70
  }
71
71
  }