Si coloco mi función así:
const sandbox: sinon.SinonSandbox = sinon.createSandbox(); getInfoStub = sandbox.stub(ytdl, 'getInfo').withArgs(videoUrl).resolves(videoInfo); Y luego trato de hacer getInfoStub.restore() Obtengo un TypeError: getInfoStub.restore is not a function
Sin embargo, cuando elimino la opción .withArgs(videoUrl) restore funciona bien:
const sandbox: sinon.SinonSandbox = sinon.createSandbox(); getInfoStub = sandbox.stub(ytdl, 'getInfo').resolves(videoInfo); ¿Cuál es el trato con withArgs que rompe sinon?
Pruebe el siguiente código:
const getInfoStub = sandbox.stub(ytdl, 'getInfo'); const result = getInfoStub.withArgs(videoUrl).resolves(videoInfo); getInfoStub.restore();Enlace de referencia: https://sinonjs.org/releases/latest/stubs/