You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a key foo that I set to bar to expire in 2 seconds. I'm testing this using redis-mock using jest fake timers. I always get -1 (no expiry associated with key).
import{promisify}from'util';import*asredisfrom'redis-mock';jest.mock('redis'=>redis)const{ redisClient, setEx }=require('./redis');constttl=promisify(redisClient.ttl).bind(redisClient);describe('redisService',()=>{it('returns the ttl for a key set using setEx',async()=>{jest.useFakeTimers();awaitsetEx('foo',2,'bar');constsec=awaitttl('foo');expect(sec).toEqual(2);jest.clearAllTimers();jest.useRealTimers();})})
The text was updated successfully, but these errors were encountered:
I have a key
foo
that I set tobar
to expire in 2 seconds. I'm testing this usingredis-mock
using jest fake timers. I always get-1
(no expiry associated with key).Node Version:
v14.17.0
redis Version:
^3.0.2
redis-mock Version:
^0.56.3
The text was updated successfully, but these errors were encountered: