2024-08-04 08:28:19 +08:00
|
|
|
import path from 'node:path';
|
2024-08-20 07:41:08 +08:00
|
|
|
import dotenv from 'dotenv';
|
2024-07-23 16:25:11 +08:00
|
|
|
import { defineConfig } from 'vitest/config';
|
2025-01-07 11:10:28 +08:00
|
|
|
import { version } from './package.json';
|
2024-07-23 16:25:11 +08:00
|
|
|
|
2024-08-20 07:41:08 +08:00
|
|
|
/**
|
|
|
|
* Read environment variables from file.
|
|
|
|
* https://github.com/motdotla/dotenv
|
|
|
|
*/
|
|
|
|
dotenv.config({
|
|
|
|
path: path.join(__dirname, '../../.env'),
|
|
|
|
});
|
2024-08-01 15:46:40 +08:00
|
|
|
|
2025-03-31 19:22:39 +08:00
|
|
|
const aiTestType = process.env.AI_TEST_TYPE;
|
|
|
|
const unitTests = ['tests/unit-test/**/*.test.ts'];
|
|
|
|
const aiWebTests = [
|
|
|
|
'tests/ai/web/**/*.test.ts',
|
|
|
|
'tests/ai/bridge/**/*.test.ts',
|
|
|
|
];
|
|
|
|
|
|
|
|
const testFiles = (() => {
|
|
|
|
switch (aiTestType) {
|
|
|
|
case 'web':
|
|
|
|
return [...aiWebTests];
|
|
|
|
default:
|
|
|
|
return unitTests;
|
|
|
|
}
|
|
|
|
})();
|
2024-08-01 15:46:40 +08:00
|
|
|
|
2024-07-23 16:25:11 +08:00
|
|
|
export default defineConfig({
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'@': path.resolve(__dirname, 'src'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
test: {
|
2024-09-06 17:19:35 +08:00
|
|
|
include: testFiles,
|
2025-05-29 10:26:18 +08:00
|
|
|
testTimeout: 3 * 60 * 1000, // Global timeout set to 3 minutes
|
2025-03-12 13:49:50 +08:00
|
|
|
dangerouslyIgnoreUnhandledErrors: !!process.env.CI, // showcase.test.ts is not stable
|
2024-07-23 16:25:11 +08:00
|
|
|
},
|
2025-01-07 11:10:28 +08:00
|
|
|
define: {
|
|
|
|
__VERSION__: `'${version}'`,
|
|
|
|
},
|
2024-07-23 16:25:11 +08:00
|
|
|
});
|