fix frontend unit tests
This commit is contained in:
parent
9e33e75fc2
commit
2979d9a110
4 changed files with 51 additions and 7 deletions
|
|
@ -10,8 +10,8 @@
|
|||
"build-storybook-pre": "(tsc -p .storybook || echo done.) && node .storybook/generate.js && node .storybook/preload-locale.js && node .storybook/preload-theme.js",
|
||||
"build-storybook": "pnpm build-storybook-pre && storybook build --webpack-stats-json storybook-static",
|
||||
"chromatic": "chromatic",
|
||||
"test": "vitest --run --globals",
|
||||
"test-and-coverage": "vitest --run --coverage --globals",
|
||||
"test": "node scripts/vitest.mjs --run --globals",
|
||||
"test-and-coverage": "node scripts/vitest.mjs --run --coverage --globals",
|
||||
"typecheck-all": "pnpm run --no-bail typecheck:vue && pnpm run --no-bail typecheck:test && pnpm run --no-bail typecheck:scripts && pnpm run --no-bail typecheck:storybook",
|
||||
"typecheck": "pnpm run typecheck:vue && pnpm run typecheck:test && pnpm run typecheck:scripts && pnpm run typecheck:storybook",
|
||||
"typecheck:vue": "vue-tsc -p tsconfig.vue.json --noEmit",
|
||||
|
|
|
|||
33
packages/frontend/scripts/vitest.mjs
Normal file
33
packages/frontend/scripts/vitest.mjs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* Hot-swaps tsconfig files to work around vite limitations.
|
||||
* Based on idea from https://github.com/vitejs/vite/discussions/8483#discussioncomment-6830634
|
||||
*/
|
||||
|
||||
import nodeFs from 'node:fs/promises';
|
||||
import nodePath from 'node:path';
|
||||
import { execa } from 'execa';
|
||||
|
||||
const rootDir = nodePath.resolve(import.meta.dirname, '../');
|
||||
const tsConfig = nodePath.resolve(rootDir, 'tsconfig.json');
|
||||
const tsConfigBak = nodePath.resolve(rootDir, 'tsconfig.json.bak');
|
||||
const tsConfigVue = nodePath.resolve(rootDir, 'tsconfig.vue.json');
|
||||
|
||||
console.log('Staging tsconfig.vue.json as tsconfig.json...');
|
||||
await nodeFs.rename(tsConfig, tsConfigBak);
|
||||
await nodeFs.copyFile(tsConfigVue, tsConfig);
|
||||
|
||||
try {
|
||||
console.log('Starting vitest...');
|
||||
await execa(
|
||||
'vitest',
|
||||
process.argv.slice(2),
|
||||
{
|
||||
stdout: process.stdout,
|
||||
stderr: process.stderr,
|
||||
},
|
||||
);
|
||||
} finally {
|
||||
console.log('Restoring original tsconfig.json...');
|
||||
await nodeFs.rm(tsConfig);
|
||||
await nodeFs.rename(tsConfigBak, tsConfig);
|
||||
}
|
||||
|
|
@ -30,7 +30,7 @@ describe('MkMediaImage', () => {
|
|||
comment: null,
|
||||
properties: {},
|
||||
...image,
|
||||
} as DriveFile,
|
||||
} as Misskey.entities.DriveFile,
|
||||
},
|
||||
global: { directives, components },
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,17 +4,28 @@
|
|||
"compilerOptions": {
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"baseUrl": "./",
|
||||
"rootDir": "../",
|
||||
"paths": {
|
||||
"@/*": ["../src/*"]
|
||||
"@/*": ["../src/*"],
|
||||
"@@/*": ["../../frontend-shared/*"]
|
||||
},
|
||||
"typeRoots": [
|
||||
"../node_modules/@types"
|
||||
"../@types",
|
||||
"../node_modules/@types",
|
||||
"../node_modules/@vue-macros",
|
||||
"../node_modules"
|
||||
],
|
||||
"types": ["node"]
|
||||
},
|
||||
"include": [
|
||||
"../lib/**/*.ts",
|
||||
"../src/**/*.ts",
|
||||
"../src/**/*.vue",
|
||||
"../@types/**/*.ts",
|
||||
"./**/*.ts",
|
||||
"../src/**/*.vue"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"../.storybook/**/*"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue