From 31f8c0302a3907bfe1f4c7cbb594bcf21c8f8c6c Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 23 Sep 2024 17:13:57 +0200 Subject: [PATCH] test: fix some tests when path contains `%` Tests should pass even if the path where the repo is cloned contains URL-significant chars. --- test/common/inspector-helper.js | 4 ++-- test/es-module/test-esm-import-meta-resolve.mjs | 2 +- test/es-module/test-esm-loader-hooks.mjs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/common/inspector-helper.js b/test/common/inspector-helper.js index 9d5e3b15aece4b..864538f245e2ea 100644 --- a/test/common/inspector-helper.js +++ b/test/common/inspector-helper.js @@ -255,8 +255,8 @@ class InspectorSession { const callFrame = message.params.callFrames[0]; const location = callFrame.location; const scriptPath = this._scriptsIdsByUrl.get(location.scriptId); - assert.strictEqual(scriptPath.toString(), - expectedScriptPath.toString(), + assert.strictEqual(decodeURIComponent(scriptPath), + decodeURIComponent(expectedScriptPath), `${scriptPath} !== ${expectedScriptPath}`); assert.strictEqual(location.lineNumber, line); return true; diff --git a/test/es-module/test-esm-import-meta-resolve.mjs b/test/es-module/test-esm-import-meta-resolve.mjs index a9c26b7aecb926..f3b153062192af 100644 --- a/test/es-module/test-esm-import-meta-resolve.mjs +++ b/test/es-module/test-esm-import-meta-resolve.mjs @@ -45,7 +45,7 @@ assert.deepStrictEqual( { default: 'some://weird/protocol' }, ); assert.deepStrictEqual( - { ...await import(`data:text/javascript,export default import.meta.resolve("baz/", ${JSON.stringify(fixtures)})`) }, + { ...await import(`data:text/javascript,export default import.meta.resolve("baz/", ${encodeURIComponent(JSON.stringify(fixtures))})`) }, { default: fixtures + 'node_modules/baz/' }, ); assert.deepStrictEqual( diff --git a/test/es-module/test-esm-loader-hooks.mjs b/test/es-module/test-esm-loader-hooks.mjs index a36e726810431e..c697a5493c6d8b 100644 --- a/test/es-module/test-esm-loader-hooks.mjs +++ b/test/es-module/test-esm-loader-hooks.mjs @@ -822,7 +822,7 @@ describe('Loader hooks', { concurrency: !process.env.TEST_PARALLEL }, () => { const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ '--no-warnings', '--experimental-loader', - `data:text/javascript,const fixtures=${JSON.stringify(fixtures.path('empty.js'))};export ${ + `data:text/javascript,const fixtures=${encodeURI(JSON.stringify(fixtures.path('empty.js')))};export ${ encodeURIComponent(function resolve(s, c, n) { if (s.endsWith('entry-point')) { return {