I have set up ts-mocha and node-fetch to run a unit test, but I am encountering the following error:
TypeError: Unknown file extension ".ts" for ...
The content of the file is as follows:
import fetch from 'node-fetch';
export default async () => {
return fetch('https://github.com/');
}
Here is my unit test:
import { expect } from 'chai';
import useFetch from './useFetch';
describe("useFetch", function() {
before(async () => {
await import ('./useFetch');
});
describe("get", async () => {
it("test", async () => {
const result = await useFetch();
expect(result).to.equal('fail');
});
});
});
The function is being executed, and when I remove the fetch call, the error disappears. How can I resolve this issue?