mirror of
https://github.com/nextcloud/spreed.git
synced 2025-12-17 21:12:20 +01:00
chore(test): migrate config to vitest
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
This commit is contained in:
parent
2de759cc11
commit
176c837c8e
7 changed files with 56 additions and 121 deletions
4
Makefile
4
Makefile
|
|
@ -72,7 +72,6 @@ appstore:
|
||||||
rm -rf $(build_dir)
|
rm -rf $(build_dir)
|
||||||
mkdir -p $(sign_dir)
|
mkdir -p $(sign_dir)
|
||||||
rsync -a \
|
rsync -a \
|
||||||
--exclude=babel.config.js \
|
|
||||||
--exclude=/build \
|
--exclude=/build \
|
||||||
--exclude=composer.patches.json \
|
--exclude=composer.patches.json \
|
||||||
--exclude=docs \
|
--exclude=docs \
|
||||||
|
|
@ -85,8 +84,7 @@ appstore:
|
||||||
--exclude=.gitattributes \
|
--exclude=.gitattributes \
|
||||||
--exclude=.github \
|
--exclude=.github \
|
||||||
--exclude=.gitignore \
|
--exclude=.gitignore \
|
||||||
--exclude=jest.config.js \
|
--exclude=vitest.config.js \
|
||||||
--exclude=jest.global.setup.js \
|
|
||||||
--exclude=.l10nignore \
|
--exclude=.l10nignore \
|
||||||
--exclude=mkdocs.yml \
|
--exclude=mkdocs.yml \
|
||||||
--exclude=Makefile \
|
--exclude=Makefile \
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
/**
|
|
||||||
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
const babelConfig = require('@nextcloud/babel-config')
|
|
||||||
|
|
||||||
module.exports = babelConfig
|
|
||||||
100
jest.config.js
100
jest.config.js
|
|
@ -1,100 +0,0 @@
|
||||||
/**
|
|
||||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
const { resolve } = require('node:path')
|
|
||||||
|
|
||||||
// Listed packages will be transformed with babel-jest
|
|
||||||
// TODO: find a way to consolidate this in one place, with webpack.common.js
|
|
||||||
const ignorePatterns = [
|
|
||||||
'@nextcloud/dialogs',
|
|
||||||
'@nextcloud/vue',
|
|
||||||
'@mdi/svg',
|
|
||||||
'@vueuse/core',
|
|
||||||
'@vueuse/router',
|
|
||||||
'@vueuse/shared',
|
|
||||||
'bail',
|
|
||||||
'ccount', // ESM dependency of remark-gfm
|
|
||||||
'comma-separated-tokens',
|
|
||||||
'decode-named-character-reference',
|
|
||||||
'devlop',
|
|
||||||
'escape-string-regexp',
|
|
||||||
'hast-.*',
|
|
||||||
'is-.*',
|
|
||||||
'longest-streak', // ESM dependency of remark-gfm
|
|
||||||
'markdown-table', // ESM dependency of remark-gfm
|
|
||||||
'mdast-.*',
|
|
||||||
'micromark',
|
|
||||||
'property-information',
|
|
||||||
'rehype-.*',
|
|
||||||
'remark-.*',
|
|
||||||
'space-separated-tokens',
|
|
||||||
'trim-lines',
|
|
||||||
'trough',
|
|
||||||
'unified',
|
|
||||||
'unist-.*',
|
|
||||||
'vfile',
|
|
||||||
'vue-material-design-icons',
|
|
||||||
'web-namespaces',
|
|
||||||
'zwitch', // ESM dependency of remark-gfm
|
|
||||||
]
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
|
|
||||||
// Allow tests in the src and in tests/unit folders
|
|
||||||
testMatch: ['<rootDir>/src/**/*.(spec|test).(ts|js)'],
|
|
||||||
// FIXME Skip tests using @nextcloud/dialogs, @nextcloud/vue, @nextcloud/upload
|
|
||||||
testPathIgnorePatterns: [
|
|
||||||
'<rootDir>/src/components',
|
|
||||||
'<rootDir>/src/store/fileUploadStore.spec.js',
|
|
||||||
],
|
|
||||||
// Transform packages from top-level and nested 'node_modules'
|
|
||||||
transformIgnorePatterns: [
|
|
||||||
`<rootDir>/node_modules/(?!(?:.*\\/node_modules\\/)?(?:${ignorePatterns.join('|')}))`,
|
|
||||||
],
|
|
||||||
resetMocks: false,
|
|
||||||
setupFiles: [],
|
|
||||||
setupFilesAfterEnv: [
|
|
||||||
'<rootDir>/src/test-setup.js',
|
|
||||||
],
|
|
||||||
globalSetup: resolve(__dirname, 'jest.global.setup.js'),
|
|
||||||
|
|
||||||
collectCoverageFrom: [
|
|
||||||
'<rootDir>/src/**/*.{js,ts,vue}',
|
|
||||||
],
|
|
||||||
|
|
||||||
testEnvironment: 'jest-environment-jsdom',
|
|
||||||
testEnvironmentOptions: {
|
|
||||||
customExportConditions: ['node', 'node-addons'],
|
|
||||||
},
|
|
||||||
|
|
||||||
moduleFileExtensions: [
|
|
||||||
'js',
|
|
||||||
'mjs',
|
|
||||||
'ts',
|
|
||||||
'vue',
|
|
||||||
],
|
|
||||||
|
|
||||||
moduleNameMapper: {
|
|
||||||
'\\.(css|scss)$': 'jest-transform-stub',
|
|
||||||
'^.+\\.svg(\\?raw)?$': '<rootDir>/src/__mocks__/svg.js',
|
|
||||||
'vendor/tflite/(.*).wasm$': '<rootDir>/src/utils/media/effects/virtual-background/vendor/tflite/$1.js',
|
|
||||||
'@matrix-org/olm/(.*).wasm$': '<rootDir>/node_modules/@matrix-org/olm/$1.js',
|
|
||||||
'^@nextcloud/dialogs': '<rootDir>/node_modules/@nextcloud/dialogs/dist/index.mjs',
|
|
||||||
'^@nextcloud/vue/(.*)/(.*)$': '<rootDir>/node_modules/@nextcloud/vue/dist/$1/$2/index.mjs',
|
|
||||||
},
|
|
||||||
|
|
||||||
transform: {
|
|
||||||
'\\.ts$': ['ts-jest', {
|
|
||||||
useESM: true,
|
|
||||||
tsconfig: {
|
|
||||||
verbatimModuleSyntax: false,
|
|
||||||
},
|
|
||||||
}],
|
|
||||||
'\\.(js|mjs)$': 'babel-jest',
|
|
||||||
'\\.vue$': '@vue/vue3-jest',
|
|
||||||
'\\.tflite$': 'jest-transform-stub',
|
|
||||||
'\\.(css|scss)$': 'jest-transform-stub',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
/**
|
|
||||||
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = () => {
|
|
||||||
process.env.TZ = 'UTC'
|
|
||||||
}
|
|
||||||
|
|
@ -20,9 +20,8 @@
|
||||||
"serve": "node --max-old-space-size=4096 ./node_modules/webpack/bin/webpack.js serve --node-env development --progress --allowed-hosts all",
|
"serve": "node --max-old-space-size=4096 ./node_modules/webpack/bin/webpack.js serve --node-env development --progress --allowed-hosts all",
|
||||||
"stylelint": "stylelint \"css/*.css\" \"css/*.scss\" \"src/**/*.scss\" \"src/**/*.vue\"",
|
"stylelint": "stylelint \"css/*.css\" \"css/*.scss\" \"src/**/*.scss\" \"src/**/*.vue\"",
|
||||||
"stylelint:fix": "stylelint \"css/*.css\" \"css/*.scss\" \"src/**/*.scss\" \"src/**/*.vue\" --fix",
|
"stylelint:fix": "stylelint \"css/*.css\" \"css/*.scss\" \"src/**/*.scss\" \"src/**/*.vue\" --fix",
|
||||||
"test": "jest",
|
"test": "vitest",
|
||||||
"test:coverage": "jest --coverage",
|
"test:coverage": "vitest run --coverage",
|
||||||
"test:watch": "jest --watch",
|
|
||||||
"typescript:check": "vue-tsc --noEmit",
|
"typescript:check": "vue-tsc --noEmit",
|
||||||
"typescript:generate": "npx openapi-typescript -t",
|
"typescript:generate": "npx openapi-typescript -t",
|
||||||
"typescript:generate-core-types": "./src/types/generate-core-types.sh",
|
"typescript:generate-core-types": "./src/types/generate-core-types.sh",
|
||||||
|
|
|
||||||
11
src/test-global-setup.js
Normal file
11
src/test-global-setup.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vitest global setup
|
||||||
|
*/
|
||||||
|
export default function setup() {
|
||||||
|
process.env.TZ = 'UTC'
|
||||||
|
}
|
||||||
42
vitest.config.js
Normal file
42
vitest.config.js
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import vue from '@vitejs/plugin-vue'
|
||||||
|
import { resolve } from 'node:path'
|
||||||
|
import { defineConfig } from 'vitest/config'
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [vue()],
|
||||||
|
assetsInclude: ['**/*.tflite', '**/*.wasm'],
|
||||||
|
test: {
|
||||||
|
include: ['src/**/*.{test,spec}.?(c|m)[jt]s?(x)'],
|
||||||
|
exclude: [
|
||||||
|
// TODO: migrate to Vue 3
|
||||||
|
'src/components/**',
|
||||||
|
// FIXME: broken after Vue 3 migration
|
||||||
|
'src/store/fileUploadStore.spec.js',
|
||||||
|
],
|
||||||
|
server: {
|
||||||
|
deps: {
|
||||||
|
// Allow importing CSS from dependencies
|
||||||
|
inline: ['@nextcloud/vue'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
alias: [
|
||||||
|
{ find: './vendor/tflite/tflite.wasm', replacement: resolve(import.meta.dirname, 'src/utils/media/effects/virtual-background/vendor/tflite/tflite.js') },
|
||||||
|
{ find: './vendor/tflite/tflite-simd.wasm', replacement: resolve(import.meta.dirname, 'src/utils/media/effects/virtual-background/vendor/tflite/tflite-simd.js') },
|
||||||
|
{ find: '@matrix-org/olm/olm.wasm', replacement: '@matrix-org/olm/olm.js' },
|
||||||
|
],
|
||||||
|
globals: true,
|
||||||
|
environment: 'jsdom',
|
||||||
|
environmentOptions: {
|
||||||
|
jsdom: {
|
||||||
|
url: 'http://localhost',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
setupFiles: ['src/test-setup.js'],
|
||||||
|
globalSetup: 'src/test-global-setup.js',
|
||||||
|
},
|
||||||
|
})
|
||||||
Loading…
Add table
Reference in a new issue