diff --git a/hiviewdfx/hisyseventtest/hisyseventjstest/src/main/js/test/HiSysEventSecond.test.js b/hiviewdfx/hisyseventtest/hisyseventjstest/src/main/js/test/HiSysEventSecond.test.js index 98d9607136131493e7f4a21188844c5859d1a20f..321da6ba84ed2b907568a2e9e25b443513b5992f 100644 --- a/hiviewdfx/hisyseventtest/hisyseventjstest/src/main/js/test/HiSysEventSecond.test.js +++ b/hiviewdfx/hisyseventtest/hisyseventjstest/src/main/js/test/HiSysEventSecond.test.js @@ -539,9 +539,9 @@ describe('hiSysEventJsSecondTest', function () { */ it('testHiSysEventApi42', 3, async function (done) { console.info('testHiSysEventApi42 start') + var watcher = [] try { - var watcher = [] - for (var i = 0; i < 30; i++) { + for (var i = 0; i < 31; i++) { watcher[i] = { rules: [{ domain: "RELIABILITY" + i, @@ -555,19 +555,25 @@ describe('hiSysEventJsSecondTest', function () { } hiSysEvent.addWatcher(watcher[i]) } - setTimeout(() => { - var watcher = [] - for (var i = 0; i < 30; i++) { - hiSysEvent.removeWatcher(watcher[i]) - } - }, 5000) - done() }catch (err) { - console.error(`testHiSysEventApi42 > error code: ${err.code}, error msg: ${err.message}`) + console.error(`testHiSysEventApi42 > addWatcher error code: ${err.code}, error msg: ${err.message}`) expect(err.code == 11200101).assertTrue() - console.info('testHiSysEventApi42 end') + console.info('testHiSysEventApi42 addWatcher end') done() } + setTimeout(() => { + try { + for (var i = 0; i < 31; i++) { + hiSysEvent.removeWatcher(watcher[i]) + } + }catch (err) { + console.error(`testHiSysEventApi42 > remove error code: ${err.code}, error msg: ${err.message}`) + expect(err.code == 11200201).assertTrue() + console.info('testHiSysEventApi42 remove end') + done() + } + }, 5000) + done() }) /**