- Instalaciones:
npm install -D jest babel-jest @babel/preset-env @babel/preset-react
npm install -D @testing-library/react @types/jest jest-environment-jsdom
- if Fetch API:
/** | |
* Creates a fetch instance with a base URL, customizable headers, and a default method depending on the environment. | |
* @param {string} endpoint - The endpoint to request. | |
* @param {Object} options - The options for the fetch request, including method and headers. | |
* @returns {Promise<Response>} The fetch promise. | |
*/ | |
function customFetch(endpoint, options = {}) { | |
// Define the base URL depending on the environment | |
const baseURL = { | |
development: 'http://localhost:3000', |