[Vuejs]-Jest cannot find module from window object in a Vue/Vuex project

0👍

If /js/settings.js is included in your page, you don’t need import it in the baz.storage.js but make sure settings.js is include at first.

Eg:

<script src="/js/settings.js"></script>
<script src="/js/script2.js"></script>
<script src="/js/script3.js"></script>

settings.js is added at first in the above example so that window.mySettings will be available for the script2.js and script3.js


once you declared a variable in the window it is declared at the global scope and it can be accessed from all the other scripts.

Eg:

console.log(window.mySettings)

Leave a comment