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: {
    "^@/assets/.*\\.(jpg|jpeg|png|gif|webp|svg)$": path.resolve(__dirname, "mocks/file.js"),
    "\\.(css)$": path.resolve(__dirname, "mocks/style.js"),
    "\\.(jpg|jpeg|png|gif|webp|svg)$": path.resolve(__dirname, "mocks/file.js"),
    "^@/(.*)$": path.resolve(frontendRoot, "src/$1"),
    "^vue$": path.resolve(frontendRoot, "node_modules/vue/dist/vue.cjs.js"),
    "^@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/**/*.js",
    "src/**/*.vue",
  ],
  coverageReporters: ["text", "lcov", "json-summary"],
};
