mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-22 12:07:37 +01:00
c3098076b5
Even if we are not bundling with `vite` yet, we can use `vitest` in place of Jest which brings a few benefits like not requiring to use `NODE_OPTIONS` to run and having sane module resolution. It's possible to also use `jest-extended` with vitest, but I opted to not do so for now because it brings heavyweight dependencies and it was trivial to just rewrite the affected matchers to be compatible. This PR also removes 153 JS dependencies, which is certainly nice. Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
34 lines
753 B
JavaScript
34 lines
753 B
JavaScript
import {defineConfig} from 'vitest/dist/config.js';
|
|
import {readFile} from 'fs/promises';
|
|
import {dataToEsm} from '@rollup/pluginutils';
|
|
import {extname} from 'path';
|
|
|
|
function stringPlugin() {
|
|
return {
|
|
name: 'string-plugin',
|
|
enforce: 'pre',
|
|
async load(id) {
|
|
const path = id.split('?')[0];
|
|
if (extname(path) !== '.svg') return null;
|
|
return dataToEsm(await readFile(path, 'utf8'));
|
|
}
|
|
};
|
|
}
|
|
|
|
export default defineConfig({
|
|
test: {
|
|
include: ['web_src/**/*.test.js'],
|
|
setupFiles: ['./web_src/js/test/setup.js'],
|
|
environment: 'jsdom',
|
|
testTimeout: 20000,
|
|
open: false,
|
|
allowOnly: true,
|
|
passWithNoTests: true,
|
|
globals: true,
|
|
watch: false,
|
|
},
|
|
plugins: [
|
|
stringPlugin(),
|
|
],
|
|
});
|