diff options
author | John Molakvoæ <skjnldsv@protonmail.com> | 2023-06-14 10:49:40 +0200 |
---|---|---|
committer | John Molakvoæ <skjnldsv@protonmail.com> | 2023-06-21 09:08:04 +0200 |
commit | f8e697ce4dd28ba8899adacf2fa12e33f60b2194 (patch) | |
tree | 98951ba5640964212ec4350170a38cb83358a951 /jest.config.ts | |
parent | 8b5ef98495597c11caba2ac1fea0416345ec2f0e (diff) | |
download | nextcloud-server-f8e697ce4dd28ba8899adacf2fa12e33f60b2194.tar.gz nextcloud-server-f8e697ce4dd28ba8899adacf2fa12e33f60b2194.zip |
feat: prepare jest upgrade and ts testing
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'jest.config.ts')
-rw-r--r-- | jest.config.ts | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/jest.config.ts b/jest.config.ts new file mode 100644 index 00000000000..37432033242 --- /dev/null +++ b/jest.config.ts @@ -0,0 +1,70 @@ +/** + * @copyright Copyright (c) 2020 Marco Ambrosini <marcoambrosini@pm.me> + * + * @author Marco Ambrosini <marcoambrosini@pm.me> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +import type { Config } from 'jest' + +// TODO: find a way to consolidate this in one place, with webpack.common.js +const ignorePatterns = [ + '@juliushaertl', + '@mdi/svg', + '@nextcloud/vue', + 'ansi-regex', + 'char-regex', + 'splitpanes', + 'string-length', + 'strip-ansi', + 'tributejs', + 'vue-material-design-icons', +] + +const config: Config = { + testMatch: ['<rootDir>/**/*.(spec|test).(ts|js)'], + modulePathIgnorePatterns: [ + '<rootDir>/apps2/', + '<rootDir>/apps-extra/', + ], + transformIgnorePatterns: [ + 'node_modules/(?!(' + ignorePatterns.join('|') + ')/)', + ], + clearMocks: true, + collectCoverageFrom: [ + '<rootDir>/**/*.{js,vue}', + ], + + setupFilesAfterEnv: ['<rootDir>/__tests__/jest-setup.ts'], + + testEnvironment: 'jest-environment-jsdom', + preset: 'ts-jest/presets/js-with-ts', + + // Allow mocking svg files + moduleDirectories: ['node_modules', '<rootDir>/'], + moduleNameMapper: { + '^.+\\.svg(\\?raw)?$': '<rootDir>/__mocks__/svg.js', + }, + + transform: { + // process `*.js` files with `babel-jest` + '^.+\\.js$': 'babel-jest', + '^.+\\.vue$': '@vue/vue2-jest', + }, +} + +export default config |