-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Labels
enhancementNew feature or requestNew feature or request
Description
I have a schedule adapter and I want to perform some checks when everything is finished (based on adapter configuration). What is the best way to wait for the adapter to stop?
Something like this?
'use strict';
const path = require('path');
const { tests, IntegrationTestHarness } = require('@iobroker/testing');
const chai = require('chai');
const expect = chai.expect;
// Run integration tests - See https://github.com/ioBroker/testing for a detailed explanation and further options
tests.integration(path.join(__dirname, '..'), {
defineAdditionalTests({ suite }) {
suite('Test', getHarness => {
/**
* @type {IntegrationTestHarness}
*/
let harness;
before(() => {
harness = getHarness();
});
it('Should work', function (done) {
this.timeout(60000);
harness.startAdapterAndWait()
.then(() => {
expect(harness.isAdapterRunning()).to.equal(true);
expect(harness.isControllerRunning()).to.equal(true);
// Wait for adapter stop
return new Promise(resolve => {
harness.on('stateChange', async (id, state) => {
if (
id === `system.adapter.${harness.adapterName}.0.alive` &&
state &&
state.val === false
) {
resolve(true);
}
});
});
})
.then(() => {
console.log('-----------------> STOPPED NOW');
done();
});
});
});
}
});Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request