I have the following code in my unit test to try and fetch a mocked up file (glb cube export from blender) to test if the renderer is functional. However, I am getting an issue with the three.js FileLoader that doesn’t make a ton of sense to me. The file is found as I can inspect the data inside the call, but the error I get here does not make sense to me…
Is there anyone here that knows what I can do so I can actually fetch the file correctly?
const test3dFile = $.get("proofscopeComponent/tests/data/cube.glb")
sinon.stub(window, 'fetch').callsFake((input, init) => {
let requestUrl;
if (input instanceof Request) {
requestUrl = input.url;
} else {
requestUrl = input;
}
if (requestUrl.includes('get_3d_model_data')) {
return test3dFile.then((data) => {
const response = new Response(data, {
status: 200,
headers: { 'Content-Type': 'model/gltf-binary' },
});
Object.defineProperty(response, 'url', { value: requestUrl });
return Promise.resolve(response);
});
}
return originalFetch(input, init);
});