0

I have a local .js file that I have to return in a mock call, but it's empty. In my spec.ts file I have this:

  import * as jsfile from "../../../assets/mocks/myFile.js";

Then in beforeEach I do:

spyOn(myService, 'getFileJS').and.returnValue(of(jsfile));

But jsfile is an empty object. What is the correct way to import the content of that file?

Usr
  • 2,280
  • 7
  • 39
  • 81
  • Does this answer your question? [How do I include a JavaScript script file in Angular and call a function from that script?](https://stackoverflow.com/questions/44817349/how-do-i-include-a-javascript-script-file-in-angular-and-call-a-function-from-th) – Toby Cook Apr 07 '21 at 08:51
  • @TobyCook I did what the answer said but it's working on my component and not in my spec.ts file – Usr Apr 07 '21 at 08:53
  • Can you share the contents of `myFile.js`? You may need to export your empty object as a variable, like so: `export const myVar = {};` – Toby Cook Apr 07 '21 at 08:57

0 Answers0