@iobroker/legacy-testing 1.0.4 → 1.0.6

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.
Files changed (3) hide show
  1. package/README.md +6 -0
  2. package/package.json +1 -1
  3. package/setup.js +33 -7
package/README.md CHANGED
@@ -14,6 +14,12 @@ Set process.env.JS_CONTROLLER_VERSION to version e.g. `5.0.5-alpha.0-20230617-46
14
14
 
15
15
  ## Changelog
16
16
  <!-- ### **WORK IN PROGRESS** -->
17
+ ### 1.0.6 (2023-12-19)
18
+ * (foxriver76) allow to specify the `rootDir`
19
+
20
+ ### 1.0.5 (2023-12-15)
21
+ * (bluefox) Added support for vis-1 testing
22
+
17
23
  ### 1.0.4 (2023-12-15)
18
24
  * (bluefox) Allowed GUI tests for tab_m.html too
19
25
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.4",
2
+ "version": "1.0.6",
3
3
  "name": "@iobroker/legacy-testing",
4
4
  "main": "setup.js",
5
5
  "files": [
package/setup.js CHANGED
@@ -3,18 +3,24 @@
3
3
  /* jslint node: true */
4
4
 
5
5
  // check if tmp directory exists
6
- const fs = require('fs');
7
- const path = require('path');
8
- const cp = require('child_process');
9
- const rootDir = path.normalize(`${__dirname}/../../../`);
10
- const pkg = require(`${rootDir}package.json`);
11
- const debug = typeof v8debug === 'object';
12
- pkg.main = pkg.main || 'main.js';
6
+ const fs = require('fs');
7
+ const path = require('path');
8
+ const cp = require('child_process');
9
+ let rootDir = path.normalize(`${__dirname}/../../../`);
10
+ const debug = typeof v8debug === 'object';
13
11
 
14
12
  let JSONLDB;
15
13
 
16
14
  let adapterName = path.normalize(rootDir).replace(/\\/g, '/').split('/');
15
+ if (adapterName[adapterName.length - 2] === 'vis-2-widgets-testing') {
16
+ rootDir = path.normalize(`${__dirname}/../../../../../../`);
17
+ adapterName = path.normalize(rootDir).replace(/\\/g, '/').split('/');
18
+ }
17
19
  adapterName = adapterName[adapterName.length - 2];
20
+
21
+ let pkg = require(`${rootDir}package.json`);
22
+ pkg.main = pkg.main || 'main.js';
23
+
18
24
  const adaptersStarted = {};
19
25
  const pids = {};
20
26
 
@@ -542,6 +548,25 @@ function clearDB() {
542
548
  }
543
549
  }
544
550
 
551
+ /** @typedef {{ rootDir?: string }} LegacyTestingOptions */
552
+
553
+ /**
554
+ * Override options
555
+ *
556
+ * @param {LegacyTestingOptions} options specify attributes which should be overridden
557
+ */
558
+ function setOptions(options) {
559
+ if (options.rootDir) {
560
+ rootDir = options.rootDir
561
+ }
562
+ }
563
+
564
+ /**
565
+ * Install js-controller and setup the adapter
566
+ *
567
+ * @param {string[]} preInstalledAdapters list of adapters which need to be installed additionally
568
+ * @param {(systemConfig: Record<string, any>) => void} cb callback
569
+ */
545
570
  function setupController(preInstalledAdapters, cb) {
546
571
  if (typeof preInstalledAdapters === 'function') {
547
572
  cb = preInstalledAdapters;
@@ -954,4 +979,5 @@ if (typeof module !== undefined && module.parent) {
954
979
  module.exports.installCustomAdapter = installCustomAdapter;
955
980
  module.exports.getObject = getObject;
956
981
  module.exports.setObject = setObject;
982
+ module.exports.setOptions = setOptions;
957
983
  }