Skip to content

Commit

Permalink
fix E2E test (3)
Browse files Browse the repository at this point in the history
  • Loading branch information
fs-eire committed Dec 2, 2024
1 parent 5750170 commit 6e437e3
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 7 deletions.
2 changes: 1 addition & 1 deletion js/web/test/e2e/browser-test-wasm-binary-override.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const documentUrl = document.currentScript.src;

it('Browser E2E testing - WebAssembly backend', async function () {
// preload .wasm file binary
const wasmUrl = new URL('./node_modules/onnxruntime-web/dist/ort-wasm-simd-threaded.wasm', documentUrl).href;
const wasmUrl = new URL('./node_modules/onnxruntime-web/dist/ort-wasm-simd-threaded.jsep.wasm', documentUrl).href;
const response = await fetch(wasmUrl);

// make sure the .wasm file is loaded successfully
Expand Down
28 changes: 28 additions & 0 deletions js/web/test/e2e/browser-test-wasm-path-override-filename-jsep.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

it('Browser E2E testing - WebAssembly backend (path override filename)', async function () {
// check base URL port from test args
if (typeof __ort_arg_port === 'undefined') {
throw new Error('test flag --port=<PORT> is required');
}
const base = `http://localhost:${__ort_arg_port}/`;

ort.env.wasm.wasmPaths = {};

if (typeof __ort_arg_files === 'string' && __ort_arg_files.includes('wasm')) {
const overrideWasmUrl = new URL('./test-wasm-path-override/jsep-renamed.wasm', base).href;
console.log(`ort.env.wasm.wasmPaths['wasm'] = ${JSON.stringify(overrideWasmUrl)};`);
ort.env.wasm.wasmPaths.wasm = overrideWasmUrl;
}

if (typeof __ort_arg_files === 'string' && __ort_arg_files.includes('mjs')) {
const overrideMjsUrl = new URL('./test-wasm-path-override/jsep-renamed.mjs', base).href;
console.log(`ort.env.wasm.wasmPaths['mjs'] = ${JSON.stringify(overrideMjsUrl)};`);
ort.env.wasm.wasmPaths.mjs = overrideMjsUrl;
}

await testFunction(ort, { executionProviders: ['wasm'] });
});
12 changes: 6 additions & 6 deletions js/web/test/e2e/run-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ const BROWSER_TEST_CASES = [

// path override:
// wasm, path override filenames for both mjs and wasm, same origin
[true, false, './browser-test-wasm-path-override-filename.js', 'ort.min.js', ['port=9876', 'files=mjs,wasm']],
[true, false, './browser-test-wasm-path-override-filename-jsep.js', 'ort.min.js', ['port=9876', 'files=mjs,wasm']],
[true, false, './browser-test-wasm-path-override-filename.js', 'ort.wasm.min.js', ['port=9876', 'files=mjs,wasm']],
// wasm, path override filenames for both mjs and wasm, cross origin
[false, true, './browser-test-wasm-path-override-filename.js', 'ort.min.js', ['port=8081', 'files=mjs,wasm']],
[false, true, './browser-test-wasm-path-override-filename-jsep.js', 'ort.min.js', ['port=8081', 'files=mjs,wasm']],
[false, true, './browser-test-wasm-path-override-filename.js', 'ort.wasm.min.js', ['port=8081', 'files=mjs,wasm']],
// wasm, path override filename for wasm, same origin
[true, false, './browser-test-wasm-path-override-filename.js', 'ort.min.js', ['port=9876', 'files=wasm']],
[true, false, './browser-test-wasm-path-override-filename-jsep.js', 'ort.min.js', ['port=9876', 'files=wasm']],
[true, false, './browser-test-wasm-path-override-filename.js', 'ort.wasm.min.js', ['port=9876', 'files=wasm']],
// wasm, path override filename for wasm, cross origin
[false, true, './browser-test-wasm-path-override-filename.js', 'ort.min.js', ['port=8081', 'files=wasm']],
[false, true, './browser-test-wasm-path-override-filename-jsep.js', 'ort.min.js', ['port=8081', 'files=wasm']],
[false, true, './browser-test-wasm-path-override-filename.js', 'ort.wasm.min.js', ['port=8081', 'files=wasm']],
// wasm, path override filename for mjs, same origin
[true, false, './browser-test-wasm-path-override-filename.js', 'ort.min.js', ['port=9876', 'files=mjs']],
[true, false, './browser-test-wasm-path-override-filename-jsep.js', 'ort.min.js', ['port=9876', 'files=mjs']],
[true, false, './browser-test-wasm-path-override-filename.js', 'ort.wasm.min.js', ['port=9876', 'files=mjs']],
// wasm, path override filename for mjs, cross origin
[false, true, './browser-test-wasm-path-override-filename.js', 'ort.min.js', ['port=8081', 'files=mjs']],
[false, true, './browser-test-wasm-path-override-filename-jsep.js', 'ort.min.js', ['port=8081', 'files=mjs']],
[false, true, './browser-test-wasm-path-override-filename.js', 'ort.wasm.min.js', ['port=8081', 'files=mjs']],
// wasm, path override prefix, same origin
[true, false, './browser-test-wasm-path-override-prefix.js', 'ort.min.js', ['port=9876']],
Expand Down
4 changes: 4 additions & 0 deletions js/web/test/e2e/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ function prepareWasmPathOverrideFiles() {
fs.copyFileSync(`${sourceFile}.wasm`, path.join(folder, 'ort-wasm-simd-threaded.wasm'));
fs.copyFileSync(`${sourceFile}.mjs`, path.join(folder, 'renamed.mjs'));
fs.copyFileSync(`${sourceFile}.wasm`, path.join(folder, 'renamed.wasm'));
fs.copyFileSync(`${sourceFile}.jsep.mjs`, path.join(folder, 'ort-wasm-simd-threaded.jsep.mjs'));
fs.copyFileSync(`${sourceFile}.jsep.wasm`, path.join(folder, 'ort-wasm-simd-threaded.jsep.wasm'));
fs.copyFileSync(`${sourceFile}.jsep.mjs`, path.join(folder, 'jsep-renamed.mjs'));
fs.copyFileSync(`${sourceFile}.jsep.wasm`, path.join(folder, 'jsep-renamed.wasm'));
}

async function testAllNodejsCases() {
Expand Down

0 comments on commit 6e437e3

Please sign in to comment.