Skip to content

Commit

Permalink
parametrize test config so it can run on firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent-Bouisset committed Jun 4, 2024
1 parent 7f6a8fe commit 2537b4d
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 27 deletions.
16 changes: 7 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,13 @@
"standalone": "node ./scripts/run_standalone_demo.mjs",
"start": "node ./scripts/start_demo_web_server.mjs",
"start:wasm": "node ./scripts/start_demo_web_server.mjs --include-wasm",
"test:vitest": "node ./tests/integration/run_vitest.mjs",
"vitest": "vitest",
"test:integration": "vitest tests/integration",
"test:integration:chrome": "node tests/integration/run.mjs --bchrome",
"test:integration:chrome:watch": "node tests/integration/run.mjs --bchrome --watch",
"test:integration:firefox": "node tests/integration/run.mjs --bfirefox",
"test:integration:firefox:watch": "node tests/integration/run.mjs --bfirefox --watch",
"test:memory": "vitest tests/memory",
"test:memory:chrome:watch": "node tests/memory/run.mjs --bchrome --watch",
"test:integration": "npm run test:integration:chrome && npm run test:integration:firefox",
"test:integration:chrome": "export BROWSER_CONFIG=chrome; vitest run tests/integration",
"test:integration:chrome:watch": "export BROWSER_CONFIG=chrome; vitest watch tests/integration",
"test:integration:firefox": "export BROWSER_CONFIG=firefox; vitest run tests/integration",
"test:integration:firefox:watch": "export BROWSER_CONFIG=firefox; vitest watch tests/integration",
"test:memory": "export BROWSER_CONFIG=chrome; vitest run tests/memory",
"test:memory:chrome:watch": "export BROWSER_CONFIG=chrome; vitest watch tests/memory",
"test:unit": "jest --maxWorkers=5",
"test:unit:coverage": "jest --coverage",
"update-version": "npm run version --git-tag-version=false",
Expand Down
71 changes: 53 additions & 18 deletions vitest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,56 @@ function vitePluginArraybuffer() {
};
}

function getBrowserConfig(browser) {
switch (browser) {
case "chrome":
return {
enabled: true,
name: "chrome",
provider: "webdriverio",
headless: true,
providerOptions: {
capabilities: {
"goog:chromeOptions": {
args: [
"--autoplay-policy=no-user-gesture-required",
"--enable-precise-memory-info",
"--js-flags=--expose-gc",
],
},
},
},
};

case "firefox":
return {
enabled: true,
name: "firefox",
provider: "webdriverio",
headless: true,
providerOptions: {
capabilities: {
"moz:firefoxOptions": {
prefs: {
"media.autoplay.default": 0,
"media.autoplay.enabled.user-gestures-needed": false,
"media.autoplay.block-webaudio": false,
"media.autoplay.ask-permission": false,
"media.autoplay.block-event.enabled": false,
"media.block-autoplay-until-in-foreground": false,
},
},
},
},
};

default:
return {
enabled: false,
};
}
}

export default defineConfig({
plugins: [vitePluginArraybuffer()],
// assetsInclude: ["**/*.bif?arraybuffer"],
Expand All @@ -38,24 +88,9 @@ export default defineConfig({
},
test: {
globals: false,
include: ["**/*.test.[jt]s?(x)"],
watch: false,
include: ["tests/**/*.test.[jt]s?(x)"],
globalSetup: "tests/integration/globalSetup.js",
browser: {
enabled: true,
name: "chrome",
provider: "webdriverio",
headless: true,
providerOptions: {
capabilities: {
"goog:chromeOptions": {
args: [
"--autoplay-policy=no-user-gesture-required",
"--enable-precise-memory-info",
"--js-flags=--expose-gc",
],
},
},
},
},
browser: getBrowserConfig(process.env.BROWSER_CONFIG),
},
});

0 comments on commit 2537b4d

Please sign in to comment.