Skip to content

Commit 9423ae4

Browse files
author
Alexander Vakrilov
authored
test: Fixed unstable timer test (NativeScript#5449)
1 parent 4ce4566 commit 9423ae4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/app/timer/timer-tests.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,18 @@ export function test_setTimeout_callbackShouldBeCleared() {
113113
export function test_setInterval_callbackCalledDuringPeriod(done) {
114114
let counter = 0;
115115
const expected = 4;
116+
const timeLimit = 300;
116117

117118
const start = TKUnit.time();
118119
// >> timer-set-expression
119120
const id = timer.setInterval(() => {
120121
// >> (hide)
121122
counter++;
122-
if (counter === 4) {
123+
if (counter === expected) {
123124
const end = TKUnit.time();
124125
timer.clearInterval(id);
125-
done(end - start > 250 ? new Error('setInterval too slow.') : null);
126+
const time = end - start;
127+
done(time > timeLimit ? new Error(`setInterval too slow. Actual time: ${time} timelimit: ${timeLimit}`) : null);
126128
}
127129
// << (hide)
128130
}, 50);

0 commit comments

Comments
 (0)