Open vamsiampolu opened 3 years ago
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).
foo
bar
redis-mock
-1
Node Version: v14.17.0 redis Version: ^3.0.2 redis-mock Version: ^0.56.3
v14.17.0
^3.0.2
^0.56.3
import { promisify } from 'util'; import * as redis from 'redis-mock'; jest.mock('redis' => redis) const { redisClient, setEx } = require('./redis'); const ttl = promisify(redisClient.ttl).bind(redisClient); describe('redisService', () => { it('returns the ttl for a key set using setEx', async () => { jest.useFakeTimers(); await setEx('foo', 2, 'bar'); const sec = await ttl('foo'); expect(sec).toEqual(2); jest.clearAllTimers(); jest.useRealTimers(); }) })
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