I'm writing a unit test using jest. The function is a loadJsonData()
. It takes in a string called URL at which the Json file can be found as well as whether or not to use user credentials. This is what my test looks like
it('should fetch JSON data successfully', async () => {
const url = '../../data/mockData.json';
const useCredentials = false;
const result = await JsonLoader.loadJsonData(url, useCredentials);
expect(result).toEqual({
// expected data from mockData.json
// ...
});
});
I have my mockData.json file at the indicated relative directory, but I can't tell if it's working. How can I feed my function the actual relative directory to the mockData.json file instead of a standard html url?