Thanks for any help.
Using jsdom, I'm trying to load a local HTML file, which itself loads a local JS file.
import jsdom from 'jsdom-no-contextify'
var fs = require('fs');
var path = require("path");
var html = fs.readFileSync(path.join(__dirname, '../src/', 'launcher.html'));
global.document = jsdom.jsdom(html, {
FetchExternalResources: ['script'],
ProcessExternalResources: ['script'],
created: function (error, window) {
console.log("created: " + error);
},
url: "file://mydir/src/js/helloworld.js"
});
global.window = document.parentWindow;
window.addEventListener('load', function () {
});
launcher.html
itself sources helloworld.js
i.e.
<script type="text/javascript" src="js/helloworld.js"></script>
However I can't access or read any variables inside helloworld.js
Regards, Sam