Category : testing

I have the following trackers blocked during Cypress tests. Cypress keeps on logging these urls in the test runner logs which is ugly and interferes with other useful log messages and assertions and increases scrolling/searching effort from the user. Is there a way to disable logging of these urls in the test runner and console ..

Read more

I have an endpoint in ExpressJS which return me an array of elements, but only this elements where type is this same as type in request query params, here is code, the endpoint return this array: [ { "type":[1,2] } ] GET request looks like this: http://localhost:3000/api/types?type=1&type=2 how to test this endpoint? I need to ..

Read more

I had a test file that defines a player object at the top. file.test.js let player; player = { qualityLevels: jest.fn(() => { return { selectedIndex: 0, 0: qualityLevel, on: qualityListener, }; }), seekable: jest.fn(() => { return { end: jest.fn().mockReturnValue(seekableEnd), }; }), } videojs.mockReturnValue(player); I moved that into a helper file called player.js player.js ..

Read more

In the eternal quest for sepation of concerns, I would like to rewrite my jest tests and move out all the data used for testing into a separate file. Example: describe(‘something’, () => { it.each` key | value ${‘foo’} | ${{ ‘this’: [‘is’, ‘a’], ‘long’: [‘js’, ‘object’] }} ${‘bar’} | ${{ ‘i’: [‘don’t’, ‘want’], ‘all’: ..

Read more

I’m desperately trying to avoid the XY problem here. Some context (This is the best use case I could come up with): Imagine you have a codebase that uses Google Search in order to crawl websites for different search queries inside the web. Meaning you have an API endpoint that takes a search query and ..

Read more

I have a class for logging errors in my application: export class LogControllerDecorator implements Controller { private readonly controller: Controller private readonly logErrorRepository: LogErrorRepository constructor(controller: Controller, logErrorRepository: LogErrorRepository) { this.controller = controller this.logErrorRepository = logErrorRepository } async handle (httpRequest: HttpRequest): Promise<HttpResponse> { const httpResponse = await this.controller.handle(httpRequest) if (httpResponse.statusCode === 500) { await this.logErrorRepository.logError(httpResponse.body.stack) } ..

Read more