const path = require("node:path");

const frontendRoot = path.resolve(__dirname, "../../frontend");

module.exports = {
  rootDir: frontendRoot,
  testEnvironment: "jsdom",
  roots: [frontendRoot, path.resolve(__dirname, "unit")],
  testMatch: ["**/*.spec.js"],
  setupFilesAfterEnv: [path.resolve(__dirname, "jest.setup.js")],
  moduleFileExtensions: ["js", "mjs", "json", "vue"],
  transform: {
    "^.+\\.vue$": "@vue/vue3-jest",
    "^.+\\.[cm]?js$": "babel-jest",
  },
  moduleNameMapper: {
    "^@vue/test-utils$": path.resolve(frontendRoot, "node_modules/@vue/test-utils/dist/vue-test-utils.cjs.js"),
    "^keycloak-js$": path.resolve(__dirname, "mocks/keycloak-js.js"),
    "^mermaid$": path.resolve(__dirname, "mocks/mermaid.js"),
  },
  coverageProvider: "v8",
  collectCoverageFrom: [
    "src/auth.js",
    "src/components/MetricRow.vue",
    "src/components/MermaidCard.vue",
    "src/components/ServiceGrid.vue",
    "src/components/StatsGrid.vue",
    "src/data/sample.js",
    "src/views/HomeView.vue",
  ],
  coverageReporters: ["text", "lcov", "json-summary"],
};
