Skip to content

Commit

Permalink
esm - fix browser tests to run (#225791)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Aug 16, 2024
1 parent 9ef11ed commit 48bf32d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/unit/browser/renderer.esm.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@

<script>
const isBuild = urlParams.get('build');
const out = !!isBuild ? 'out-build' : 'out';
const tasks =[];

// configure loader
const baseUrl = window.location.href;


// generate import map
const importMapParent = document.currentScript.parentNode;
const importMap = {
imports: {
vs: new URL(`../../../${!!isBuild ? 'out-build' : 'out'}/vs`, baseUrl).href,
vs: new URL(`../../../${out}/vs`, baseUrl).href,
assert: new URL('../assert-esm.js', baseUrl).href,
sinon: new URL('../../../node_modules/sinon/pkg/sinon-esm.js', baseUrl).href,
'sinon-test': new URL('../../../node_modules/sinon-test/dist/sinon-test-es.js', baseUrl).href,
Expand Down Expand Up @@ -80,7 +80,7 @@
tasks.push(new Response(new Blob([cssData], {type:'application/octet-binary'}).stream().pipeThrough(new DecompressionStream('gzip'))).text().then(value => {
const cssModules = value.split(',');
for (const cssModule of cssModules) {
const cssUrl = new URL(`../../../out/${cssModule}`, baseUrl).href;
const cssUrl = new URL(`../../../${out}/${cssModule}`, baseUrl).href;
const jsSrc = `globalThis._VSCODE_CSS_LOAD('${cssUrl}');\n`;
const blob = new Blob([jsSrc], { type: 'application/javascript' });
importMap.imports[cssUrl] = URL.createObjectURL(blob);
Expand Down Expand Up @@ -193,8 +193,8 @@
async function loadModules(modules) {
for (const file of modules) {
mocha.suite.emit(Mocha.Suite.constants.EVENT_FILE_PRE_REQUIRE, globalThis, file, mocha);
const m = await new Promise((resolve, reject) => import(`../../../out/${file}.js`).then(resolve, err => {
console.log("BAD " + file + JSON.stringify(err, undefined, '\t'));
const m = await new Promise((resolve, reject) => import(`../../../${out}/${file}.js`).then(resolve, err => {
console.log("BAD" + file + JSON.stringify(err, undefined, '\t'));
resolve({});
}));
mocha.suite.emit(Mocha.Suite.constants.EVENT_FILE_REQUIRE, m, file, mocha);
Expand Down

0 comments on commit 48bf32d

Please sign in to comment.