From 707f4b427f6afe99cced687b5ae1d532113cd073 Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Mon, 26 Jul 2021 00:01:24 -0400 Subject: [PATCH] add a test that should fail on windows --- scripts/js-api-tests.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/scripts/js-api-tests.js b/scripts/js-api-tests.js index 33bb06d3da4..4a79c1fbd20 100644 --- a/scripts/js-api-tests.js +++ b/scripts/js-api-tests.js @@ -60,6 +60,30 @@ let buildTests = { } }, + async windowsBackslashPathTest({ esbuild, testDir }) { + let entry = path.join(testDir, 'entry.js'); + let nested = path.join(testDir, 'nested.js'); + let outfile = path.join(testDir, 'out.js'); + + // On Windows, backslash and forward slash should be treated the same + fs.writeFileSync(entry, ` + import ${JSON.stringify('./' + path.basename(nested))} + import ${JSON.stringify('.' + path.sep + path.basename(nested))} + `); + fs.writeFileSync(nested, `console.log('once')`); + + const result = await esbuild.build({ + entryPoints: [entry], + outfile, + bundle: true, + write: false, + minify: true, + format: 'esm', + }) + + assert.strictEqual(result.outputFiles[0].text, 'console.log("once");\n') + }, + async workingDirTest({ esbuild, testDir }) { let aDir = path.join(testDir, 'a'); let bDir = path.join(testDir, 'b');