2021-12-25 15:44:24 +00:00
|
|
|
/*
|
2022-04-30 15:53:02 +00:00
|
|
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
2021-12-25 15:44:24 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
import nextJest from 'next/jest'
|
|
|
|
|
|
|
|
const createJestConfig = nextJest({
|
|
|
|
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
|
2022-01-26 16:14:28 +00:00
|
|
|
dir: './'
|
2021-12-25 15:44:24 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
// Add any custom config to be passed to Jest
|
|
|
|
const customJestConfig = {
|
2023-08-13 18:28:53 +00:00
|
|
|
setupFilesAfterEnv: ['@testing-library/jest-dom/jest-globals'],
|
2021-12-25 15:44:24 +00:00
|
|
|
moduleNameMapper: {
|
|
|
|
// Handle module aliases (this will be automatically configured for you soon)
|
2022-01-26 16:14:28 +00:00
|
|
|
'^@/components/(.*)$': '<rootDir>/src/components/$1',
|
2022-04-30 15:53:02 +00:00
|
|
|
// fix uuid / jest problem https://github.com/uuidjs/uuid/pull/616
|
2022-07-30 21:32:19 +00:00
|
|
|
'^uuid$': require.resolve('uuid')
|
2021-12-25 15:44:24 +00:00
|
|
|
},
|
2022-07-30 21:32:19 +00:00
|
|
|
roots: ['<rootDir>/src'],
|
2022-03-28 19:38:03 +00:00
|
|
|
testEnvironment: 'jsdom',
|
2022-07-30 21:32:19 +00:00
|
|
|
testPathIgnorePatterns: ['/node_modules/', '/cypress/']
|
2021-12-25 15:44:24 +00:00
|
|
|
}
|
|
|
|
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
|
2023-02-05 21:05:02 +00:00
|
|
|
module.exports = async () => {
|
|
|
|
const nextJestConfig = await createJestConfig(customJestConfig)()
|
|
|
|
return {
|
|
|
|
...nextJestConfig,
|
|
|
|
moduleNameMapper: {
|
|
|
|
...nextJestConfig.moduleNameMapper,
|
|
|
|
'^.+\\.(svg)$': '<rootDir>/src/test-utils/svg-mock.tsx',
|
|
|
|
'^react-bootstrap-icons$': '<rootDir>/src/test-utils/bootstrap-icon-mocks.tsx',
|
|
|
|
'^react-bootstrap-icons/dist/icons/.*$': '<rootDir>/src/test-utils/svg-mock.tsx'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|