Skip to content
Advertisement

Tag: testing

Jest TypeError: fetch is not a function

I have the following Jest test code to test a fetch to an endpoint: But I am getting: I know that the movieApiService.getPopularMovies() is a JavaScript fetch request, but Node.js does not have the fetch API, so how I can I make this test to work using Jest? Answer I can’t test this with the code you supply, but installing

Invalidate node cache when using Jest

I have a file with object that gets populated with process.env properties: env.js Now I try to test this file with different process.env properties: env.test.js Unfortunately, even though I try to load the file in every test separately the file gets loaded only once, making the third test fail with: P.S. It doesn’t fail when I run the test alone.

Setup Cypress.io to access a page through a proxy

Is it possible to setup cypress.io to access pages through a proxy? I have a proxy that I need to go through, in order to test my application. Is there anyway to configure cypress.io to honour the standard HTTP_PROXY environment variables.. or is there some other setup that is required? Answer Update: This is now well documented at: https://docs.cypress.io/guides/references/proxy-configuration.html Unix

How to mock functions in the same module using Jest?

What’s the best way to correctly mock the following example? The problem is that after import time, foo keeps the reference to the original unmocked bar. module.js: module.test.js: I could change: to: but this is pretty ugly in my opinion to do everywhere. Answer fwiw, the solution I settled on was to use dependency injection, by setting a default argument.

ES6 import for ‘ava’ test not working

I followed the docs to create my first test using ava but it doesn’t seem to run properly. I get the error below. I tried adding import ‘babel-register’; at the top of the file, and it works, but only if I run one specific test file. e.g. ava ./test/helpers/test_helper.js. Running ava on its own though… results in the import error

Testing browser extensions

I’m going to write bunch of browser extensions (the same functionality for each popular browser). I hope, that some of the code will be shared, but I’m not sure about this yet. For sure some of extensions will use native API. I have not much experience with TDD/BDD, and I thought it’s good time to start folowing these ideas from

Lightweight web browser for testing

I have e very specific test setup in mind. I would like to start a web-browser that understands Javascript and can use HTTP proxy, point it to a URL (ideally by specifying it in the command line along with the proxy config), wait for the page to load while listening (in the proxy) requests are generated as web-page is rendered

Advertisement