Relative Content

Tag Archive for jestjs

Resolving Jest Timeout Error When Testing JavaScript Injection into Document Head

I have a product code that injects javascript into document head. I want to write unit test for it. The problem is that jest fails with timeout error. I understand it’s the resolve method of Promise that needs to be called, but I am unable to figure out how will I do it with jest. I tried to create document from JSDOM, but in that approach as well, the promise will not be resolved.

How to modify a filepath relative to the tested file in jest?

I have a test function that uses a file in the following path in my nestjs application:
/Users/username/Documents/projectname/src/assets/responses/message.hbs
This path is provided by a file service and is build from the application path, that is:
'application path'+'assets/responses/message.hbs'

What does this Jest mockAxiosFunc do?

beforeEach(() => { mockAxiosFunc.post.mockImplementation((addres) => { if(addres == XXXX) { return Promise.resolve({res: XXXX}) } return Promise.reject(XXXX) }) }) I checked the relevant code and there does not seem to be a trigger either jestjs New contributor cindy is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out […]