I'm using Vitest to test my JavaScript project that uses the Three.js graphics library. The generateRandomMoves function in cube.js doesn't depend on anything in index.js to run. The test appears to fail because cube.js imports index.js, which imports the Three.js file orbitcontrols.js. My goal is to test functions in cube.js using Vitest. How do I do resolve the issue I am facing to do this?
Directory structure
cube.test.js
import { generateRandomMoves } from "./cube.js";
it("should return an array of random moves with a length of 'difficulty'", () => {
// Arrange
const difficulty = 2;
// Act
const randomMoves = generateRandomMoves(difficulty);
// Assert
expect(randomMoves.length).toBe(difficulty);
});
cube.js imports
index.js imports
Error message: