Answer the question
In order to leave comments, you need to log in
How to define alias path for jest-puppeteer?
When trying to run tests, jest swears that it cannot find files in which let it be registered through alias.
Example:
import ROUTER_NAMES from "@/app/auth/core/router-const"
moduleNameMapper: {
"^@/(.*)$'": "<rootDir>/src/$1"
...
// jest.config.js
const { defaults } = require(`jest-config`);
const puppeteerModes = [`acceptance`, `integration`];
const { TEST_MODE } = process.env;
const PUPPETEER_MODE = puppeteerModes.includes(TEST_MODE);
module.exports = {
preset: PUPPETEER_MODE ? `jest-puppeteer` : '@vue/cli-plugin-unit-jest',
setupFiles: [
PUPPETEER_MODE ? '<rootDir>/tests/unit/integration/setup.js' : "<rootDir>/tests/unit/setup.js"
],
setupFilesAfterEnv: [`<rootDir>/tests/unit/integration/after-env.js`],
testMatch: TEST_MODE === `integration` ? [
`**/?(*.)+(integration).[tj]s?(x)`,
] : defaults.testMatch,
testURL: `http://localhost:8080`,
testPathIgnorePatterns: [
"node_modules/(?!(vuetify)/)"
],
moduleNameMapper: {
"^@/(.*)$'": "<rootDir>/src/$1",
"^vuetify/lib$": "vuetify"
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question