midscene/packages/web-integration/vitest.config.ts
Zhou Xiao edf0871fea
feat(browser): Add the forceSameTabNavigation configuration to prevent AI from opening new pages during operations, thus avoiding task interruptions. (#389)
* feat(tab-control): enhance the configuration to limit AI from opening new tabs during operations, preventing failures.

* chore: optimize evaluate error

* chore: resolve navigation error

* fix(browser): add forceSameTabNavigation config toe limit open new tab

* chore: upgrade vitest version

* fix: typo (#390)

---------

Co-authored-by: yuyutaotao <167746126+yuyutaotao@users.noreply.github.com>
2025-02-14 21:54:47 +08:00

48 lines
1.1 KiB
TypeScript

import path from 'node:path';
//@ts-ignore
import dotenv from 'dotenv';
import { defineConfig } from 'vitest/config';
import { version } from './package.json';
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
dotenv.config({
path: path.join(__dirname, '../../.env'),
});
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 aiNativeTests = ['tests/ai/native/**/*.test.ts'];
// const aiNativeTests = ['tests/ai/native/appium/dongchedi.test.ts'];
const testFiles = (() => {
switch (aiTestType) {
case 'web':
return [...aiWebTests];
case 'native':
return [...aiNativeTests];
default:
return unitTests;
}
})();
export default defineConfig({
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
test: {
include: testFiles,
testTimeout: 3 * 60 * 1000, // Global timeout set to 10 seconds
},
define: {
__VERSION__: `'${version}'`,
},
});