import { puppeteerLauncher } from "@web/test-runner-puppeteer";

export default {
  nodeResolve: true,
  files: ["test/**/*.test.js"],
  coverage: true,
  browsers: [
    puppeteerLauncher({
      launchOptions: {
        // 'new' is the modern headless mode that supports more features
        headless: "new",
        args: [
          "--no-sandbox",
          "--disable-setuid-sandbox",

          // Force GPU and WebGL using ANGLE + SwiftShader (CPU)
          // This combination is often more reliable in CI/Headless than --use-gl=swiftshader alone
          "--use-gl=angle",
          "--use-angle=swiftshader",
          "--enable-webgl",
          "--ignore-gpu-blocklist",

          // Performance / Stability flags
          "--no-first-run",
          "--disable-extensions",
          "--disable-dev-shm-usage", // Prevent shared memory crashes in Docker/CI
          "--mute-audio",
        ],
      },
    }),
  ],
  testFramework: {
    config: {
      ui: "bdd",
      // WebGL initialization in software mode can be slow, so we bump the timeout
      timeout: "20000",
    },
  },
  // Increase timeout for test runner to finish (default is 120s)
  testsFinishTimeout: 180000, // 3 minutes
};
