Weiter zum Inhalt
  • Home
  • Aktuell
  • Tags
  • 0 Ungelesen 0
  • Kategorien
  • Unreplied
  • Beliebt
  • GitHub
  • Docu
  • Hilfe
Skins
  • Hell
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dunkel
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Standard: (Kein Skin)
  • Kein Skin
Einklappen
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Deutsch
  3. Error/Bug
  4. iobroker/testing error

NEWS

  • Monatsrückblick Januar/Februar 2026 ist online!
    BluefoxB
    Bluefox
    18
    1
    770

  • Jahresrückblick 2025 – unser neuer Blogbeitrag ist online! ✨
    BluefoxB
    Bluefox
    18
    1
    6.2k

  • Neuer Blogbeitrag: Monatsrückblick - Dezember 2025 🎄
    BluefoxB
    Bluefox
    13
    1
    1.5k

iobroker/testing error

Geplant Angeheftet Gesperrt Verschoben Gelöst Error/Bug
test
4 Beiträge 2 Kommentatoren 454 Aufrufe 1 Beobachtet
  • Älteste zuerst
  • Neuste zuerst
  • Meiste Stimmen
Antworten
  • In einem neuen Thema antworten
Anmelden zum Antworten
Dieses Thema wurde gelöscht. Nur Nutzer mit entsprechenden Rechten können es sehen.
  • 孙善明孙 Offline
    孙善明孙 Offline
    孙善明
    schrieb am zuletzt editiert von 孙善明
    #1

    I wrote an adapter, but the following error occurred during automated testing, I need a little help

    travis-ci log
    github source

    "@iobroker/testing": "^1.2.5",
    
    The command "npm run test:package" exited with 0.
    1.37s$ npm run test:unit
    > iobroker.serve@0.0.1 test:unit /home/travis/build/smarthomefans/ioBroker.serve
    > mocha test/unit --exit
      Test the adapter (in a mocked environment)
        1) The adapter starts in normal mode
        2) The adapter starts in compact mode
      0 passing (78ms)
      2 failing
      1) Test the adapter (in a mocked environment)
           The adapter starts in normal mode:
         Error: Cannot find module '/home/travis/build/smarthomefans/iobroker.js-controller/lib/tools.js'
          at loadModuleInternal (node_modules/@iobroker/testing/build/tests/unit/harness/loader.js:166:26)
          at Module.fakeRequire [as require] (node_modules/@iobroker/testing/build/tests/unit/harness/loader.js:36:16)
          at require (internal/module.js:20:19)
          at startAdapter (main.js:36:58)
          at __dirname (main.js:151:2)
          at Object.<anonymous> (main.js:153:3)
          at Module.module._compile (node_modules/@iobroker/testing/build/tests/unit/harness/loader.js:158:24)
          at Object.replaceJsLoader (node_modules/@iobroker/testing/build/tests/unit/harness/loader.js:162:9)
          at require (internal/module.js:20:19)
          at loadModuleInternal (node_modules/@iobroker/testing/build/tests/unit/harness/loader.js:166:26)
          at Object.loadModuleInHarness (node_modules/@iobroker/testing/build/tests/unit/harness/loader.js:185:12)
          at Object.<anonymous> (node_modules/@iobroker/testing/build/tests/unit/harness/startMockAdapter.js:79:45)
          at next (native)
          at /home/travis/build/smarthomefans/ioBroker.serve/node_modules/@iobroker/testing/build/tests/unit/harness/startMockAdapter.js:8:71
          at __awaiter (node_modules/@iobroker/testing/build/tests/unit/harness/startMockAdapter.js:4:12)
          at Object.startMockAdapter (node_modules/@iobroker/testing/build/tests/unit/harness/startMockAdapter.js:36:12)
          at Context.<anonymous> (node_modules/@iobroker/testing/build/tests/unit/index.js:65:83)
          at next (native)
          at /home/travis/build/smarthomefans/ioBroker.serve/node_modules/@iobroker/testing/build/tests/unit/index.js:9:71
          at __awaiter (node_modules/@iobroker/testing/build/tests/unit/index.js:5:12)
          at Context.<anonymous> (node_modules/@iobroker/testing/build/tests/unit/index.js:61:20)
      2) Test the adapter (in a mocked environment)
           The adapter starts in compact mode:
         Error: Cannot find module '/home/travis/build/smarthomefans/iobroker.js-controller/lib/tools.js'
          at loadModuleInternal (node_modules/@iobroker/testing/build/tests/unit/harness/loader.js:166:26)
          at Module.fakeRequire [as require] (node_modules/@iobroker/testing/build/tests/unit/harness/loader.js:36:16)
          at require (internal/module.js:20:19)
          at startAdapter (main.js:36:58)
          at Object.<anonymous> (node_modules/@iobroker/testing/build/tests/unit/harness/startMockAdapter.js:89:17)
          at next (native)
          at /home/travis/build/smarthomefans/ioBroker.serve/node_modules/@iobroker/testing/build/tests/unit/harness/startMockAdapter.js:8:71
          at __awaiter (node_modules/@iobroker/testing/build/tests/unit/harness/startMockAdapter.js:4:12)
          at Object.startMockAdapter (node_modules/@iobroker/testing/build/tests/unit/harness/startMockAdapter.js:36:12)
          at Context.<anonymous> (node_modules/@iobroker/testing/build/tests/unit/index.js:80:105)
          at next (native)
          at /home/travis/build/smarthomefans/ioBroker.serve/node_modules/@iobroker/testing/build/tests/unit/index.js:9:71
          at __awaiter (node_modules/@iobroker/testing/build/tests/unit/index.js:5:12)
          at Context.<anonymous> (node_modules/@iobroker/testing/build/tests/unit/index.js:76:24)
    npm ERR! Linux 4.4.0-101-generic
    npm ERR! argv "/home/travis/.nvm/versions/node/v6.17.1/bin/node" "/home/travis/.nvm/versions/node/v6.17.1/bin/npm" "run" "test:unit"
    npm ERR! node v6.17.1
    npm ERR! npm  v3.10.10
    npm ERR! code ELIFECYCLE
    npm ERR! iobroker.serve@0.0.1 test:unit: `mocha test/unit --exit`
    npm ERR! Exit status 2
    npm ERR! 
    npm ERR! Failed at the iobroker.serve@0.0.1 test:unit script 'mocha test/unit --exit'.
    npm ERR! Make sure you have the latest version of node.js and npm installed.
    npm ERR! If you do, this is most likely a problem with the iobroker.serve package,
    npm ERR! not with npm itself.
    npm ERR! Tell the author that this fails on your system:
    npm ERR!     mocha test/unit --exit
    npm ERR! You can get information on how to open an issue for this project with:
    npm ERR!     npm bugs iobroker.serve
    npm ERR! Or if that isn't available, you can get their info via:
    npm ERR!     npm owner ls iobroker.serve
    npm ERR! There is likely additional logging output above.
    npm ERR! Please include the following file with any support request:
    npm ERR!     /home/travis/build/smarthomefans/ioBroker.serve/npm-debug.log
    The command "npm run test:unit" exited with 1.
    

    @Bluefox

    1 Antwort Letzte Antwort
    0
    • 孙善明孙 孙善明

      solved

      dataDir = path.normalize(utils.controllerDir + '/iobroker-data/')
      
      AlCalzoneA Offline
      AlCalzoneA Offline
      AlCalzone
      Developer
      schrieb am zuletzt editiert von AlCalzone
      #4

      @孙善明 If you are relying on files from js-controller (like tools.js), you need to mock the methods in order to use them in unit tests. Remember, those don't have a real js-controller in the background.
      This is documented here: https://github.com/ioBroker/testing#adapter-startup-unit-test (in the middle of the code block). You would have to mock getDefaultDataDir, like this:

      "{CONTROLLER_DIR}/lib/tools.js": {
          getDefaultDataDir() { return "../../iobroker-data"; }
      },
      

      (I'm not 100% sure about the actual return value).

      Warum `sudo` böse ist: https://forum.iobroker.net/post/17109

      1 Antwort Letzte Antwort
      0
      • 孙善明孙 Offline
        孙善明孙 Offline
        孙善明
        schrieb am zuletzt editiert von
        #2

        I found the problem here.

         * @param {Partial<ioBroker.AdapterOptions>} [options]
         */
        function startAdapter(options) {
        	// Create the adapter and define its methods
        	dataDir = path.normalize(path.join(utils.controllerDir, require(path.join(utils.controllerDir, 'lib', 'tools.js')).getDefaultDataDir()));
        
        	return adapter = utils.adapter(Object.assign({}, options, {
        		name: "serve",
        
        		// The ready callback is called when databases are connected and adapter received configuration.
        		// start here!
        		ready: main, // Main method defined below for readability
        
        		// is called when adapter shuts down - callback has to be called under any circumstances!
        		unload: (callback) => {
        			try {
        				adapter.log.info("cleaned everything up...");
        				callback();
        			} catch (e) {
        				callback();
        			}
        		},
        
        1 Antwort Letzte Antwort
        0
        • 孙善明孙 Offline
          孙善明孙 Offline
          孙善明
          schrieb am zuletzt editiert von
          #3

          solved

          dataDir = path.normalize(utils.controllerDir + '/iobroker-data/')
          
          AlCalzoneA 1 Antwort Letzte Antwort
          0
          • 孙善明孙 孙善明

            solved

            dataDir = path.normalize(utils.controllerDir + '/iobroker-data/')
            
            AlCalzoneA Offline
            AlCalzoneA Offline
            AlCalzone
            Developer
            schrieb am zuletzt editiert von AlCalzone
            #4

            @孙善明 If you are relying on files from js-controller (like tools.js), you need to mock the methods in order to use them in unit tests. Remember, those don't have a real js-controller in the background.
            This is documented here: https://github.com/ioBroker/testing#adapter-startup-unit-test (in the middle of the code block). You would have to mock getDefaultDataDir, like this:

            "{CONTROLLER_DIR}/lib/tools.js": {
                getDefaultDataDir() { return "../../iobroker-data"; }
            },
            

            (I'm not 100% sure about the actual return value).

            Warum `sudo` böse ist: https://forum.iobroker.net/post/17109

            1 Antwort Letzte Antwort
            0

            Hey! Du scheinst an dieser Unterhaltung interessiert zu sein, hast aber noch kein Konto.

            Hast du es satt, bei jedem Besuch durch die gleichen Beiträge zu scrollen? Wenn du dich für ein Konto anmeldest, kommst du immer genau dorthin zurück, wo du zuvor warst, und kannst dich über neue Antworten benachrichtigen lassen (entweder per E-Mail oder Push-Benachrichtigung). Du kannst auch Lesezeichen speichern und Beiträge positiv bewerten, um anderen Community-Mitgliedern deine Wertschätzung zu zeigen.

            Mit deinem Input könnte dieser Beitrag noch besser werden 💗

            Registrieren Anmelden
            Antworten
            • In einem neuen Thema antworten
            Anmelden zum Antworten
            • Älteste zuerst
            • Neuste zuerst
            • Meiste Stimmen


            Support us

            ioBroker
            Community Adapters
            Donate

            608

            Online

            32.8k

            Benutzer

            82.7k

            Themen

            1.3m

            Beiträge
            Community
            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
            ioBroker Community 2014-2025
            logo
            • Anmelden

            • Du hast noch kein Konto? Registrieren

            • Anmelden oder registrieren, um zu suchen
            • Erster Beitrag
              Letzter Beitrag
            0
            • Home
            • Aktuell
            • Tags
            • Ungelesen 0
            • Kategorien
            • Unreplied
            • Beliebt
            • GitHub
            • Docu
            • Hilfe