How to use the node-fetch.__setShouldReject function in node-fetch

To help you get started, we’ve selected a few node-fetch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vutran / zel / __tests__ / utils.js View on Github external
it('should handle rejections', async () => {
            fetch.__setShouldReject(true);
            fetch.__setResponse('THIS IS A REJECTION');

            try {
                await get('https://rejected.com');
            } catch (err) {
                expect(err).toBe('THIS IS A REJECTION');
            }
        });
    });