nocobase/scripts/codegen.setup.ts
被雨水过滤的空气-Rain 70b61c60c0
chore(e2e): make stability (#2751)
2023-10-06 18:59:59 +08:00

33 lines
846 B
TypeScript

import { execSync } from 'node:child_process';
import { commonConfig, runNocoBase } from './utils';
const runCodegenSync = () => {
try {
execSync(
`npx playwright codegen --load-storage=playwright/.auth/codegen.auth.json http://localhost:${process.env.APP_PORT} --save-storage=playwright/.auth/codegen.auth.json`,
commonConfig,
);
} catch (err) {
if (err.message.includes('auth.json')) {
execSync(
`npx playwright codegen http://localhost:${process.env.APP_PORT} --save-storage=playwright/.auth/codegen.auth.json`,
commonConfig,
);
} else {
console.error(err);
}
}
};
const run = async () => {
const { kill, awaitForNocoBase } = await runNocoBase();
await awaitForNocoBase();
console.log('Starting codegen...');
runCodegenSync();
kill?.('SIGKILL');
};
run();