How to use @iobroker/testing - 10 common examples

To help you get started, we’ve selected a few @iobroker/testing examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ioBroker / ioBroker.hm-rega / test / integrationAdapter.js View on Github external
'use strict';

const path = require('path');
const {tests} = require('@iobroker/testing');

// Run tests
tests.integration(path.join(__dirname, '..'), {

    defineAdditionalTests(getHarness) {

        describe('Test sendTo()', () => {

            it('Should work', () => {
                return new Promise(resolve => {
                    // Create a fresh harness instance each test!
                    const harness = getHarness();
                    // Start the adapter and wait until it has started
                    harness.startAdapterAndWait().then(() => {

                        harness.sendTo('hm-rega.0', 'test', 'message', (resp) => {
                            console.dir(resp);
                            resolve();
                        });
github ioBroker / ioBroker.hm-rpc / test / integrationAdapter.js View on Github external
'use strict';

const path = require('path');
const {tests} = require('@iobroker/testing');

// Run tests
tests.integration(path.join(__dirname, '..'), {
    defineAdditionalTests(getHarness) {

        describe('Test sendTo()', () => {
            it('Should work', () => {
                return new Promise(resolve => {
                    // Create a fresh harness instance each test!
                    const harness = getHarness();
                    // Start the adapter and wait until it has started
                    harness.startAdapterAndWait().then(() => {

                        harness.sendTo('hm-rpc.0', 'test', 'message', (resp) => {
                            console.dir(resp);
                            resolve();
                        });
                    });
                });
github Zefau / ioBroker.hue-extended / test / unit.js View on Github external
const path = require('path');
const { tests } = require('@iobroker/testing');

// Run unit tests - See https://github.com/ioBroker/testing for a detailed explanation and further options
tests.unit(path.join(__dirname, '..'), { "allowedExitCodes": [11] });
github iobroker-community-adapters / ioBroker.sourceanalytix / test / unit.js View on Github external
const path = require("path");
const { tests } = require("@iobroker/testing");

// Run unit tests - See https://github.com/ioBroker/testing for a detailed explanation and further options
tests.unit(path.join(__dirname, ".."),{
    defineMockBehavior(db, adapter) {
        adapter.objects.getObjectView.returns({rows: []});
    }
});
github ioBroker / ioBroker.hm-rega / test / unitAdapter.js View on Github external
'use strict';

const path = require('path');
const {tests} = require('@iobroker/testing');

// Run tests
tests.unit(path.join(__dirname, '..'));
github Zefau / ioBroker.roomba / test / unit.js View on Github external
const path = require('path');
const { tests } = require('@iobroker/testing');

// Run unit tests - See https://github.com/ioBroker/testing for a detailed explanation and further options
tests.unit(path.join(__dirname, '..'), { "allowedExitCodes": [11] });
github Apollon77 / ioBroker.tuya / test / unit.js View on Github external
const path = require('path');
const { tests } = require('@iobroker/testing');

// Run unit tests - See https://github.com/ioBroker/testing for a detailed explanation and further options
tests.unit(path.join(__dirname, '..'), { startTimeout: 10000 });
github ioBroker / ioBroker.admin / test / unit.js View on Github external
const path = require('path');
const { tests } = require('@iobroker/testing');

const jscToolsMock = {
	// No update checks in unit tests
	getInstalledInfo() { return {}; },
};
const jscLEMock = {
	// No https/letsencrypt in unit tests
	createServer(app) { return require("http").createServer(app); }
};

// Run unit tests - See https://github.com/ioBroker/testing for a detailed explanation and further options
tests.unit(path.join(__dirname, '..'), {
	additionalMockedModules: {
		"{CONTROLLER_DIR}/lib/tools.js": jscToolsMock,
		"{CONTROLLER_DIR}/lib/tools": jscToolsMock,
		"{CONTROLLER_DIR}/lib/letsencrypt.js": jscLEMock,
		"{CONTROLLER_DIR}/lib/letsencrypt": jscLEMock,
	}
});
github SchumyHao / ioBroker.miio / test / unit.js View on Github external
const path = require("path");
const {
    tests,
    utils
} = require("@iobroker/testing");
const MiioControllerClass = require("../lib/miio");
const {
    expect
} = require("chai");

// Run unit tests - See https://github.com/ioBroker/testing for a detailed explanation and further options
tests.unit(path.join(__dirname, ".."), {
    defineAdditionalTests() {
        // Create mocks and asserts
        const {
            adapter,
            database
        } = utils.unit.createMocks();
        const controller = new MiioControllerClass({});
        let deviceId = 1;

        /**
         * 
         * @param {string} vendor 
         * @param {string} type 
         * @param {string} version 
         */
        function runOneDeviceTest(vendor, type, version, states) {
github ioBroker / ioBroker.hm-rpc / test / unitAdapter.js View on Github external
'use strict';
const path = require('path');
const {tests} = require('@iobroker/testing');

// Run tests
tests.unit(path.join(__dirname, '..'), {
    defineMockBehavior(db, adapter) {
        adapter.getObjectView.returns({rows: []});
    }
});

@iobroker/testing

Shared utilities for adapter and module testing in ioBroker

MIT
Latest version published 2 months ago

Package Health Score

75 / 100
Full package analysis