Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Ensure environment variables are read.
const path = require("path");
const fs = require("fs-extra");
const dotenv = require("dotenv");
process.env = {
...process.env,
...dotenv.parse(fs.readFileSync(path.resolve(process.cwd(), ".env"))),
};
const fetchPolyfill = require("whatwg-fetch");
global.fetch = fetchPolyfill.fetch;
global.Request = fetchPolyfill.Request;
global.Headers = fetchPolyfill.Headers;
global.Response = fetchPolyfill.Response;
const axios = require("axios");
const httpAdapter = require("axios/lib/adapters/http");
axios.defaults.adapter = httpAdapter;
require("moment-timezone");
jest.doMock("moment", () => {
const moment = jest.requireActual("moment");
moment.tz.setDefault("America/New_York");
return moment;
});
const mockAsyncStorage = require("@react-native-community/async-storage/jest/async-storage-mock");