Skip to content

Commit

Permalink
chore: Improve test stability
Browse files Browse the repository at this point in the history
  • Loading branch information
spring-raining committed Jan 14, 2025
1 parent a2e2a10 commit 120edd3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 0 additions & 4 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ export function runExitHandlers() {

const exitSignals = ['exit', 'SIGINT', 'SIGTERM'];
exitSignals.forEach((sig) => {
// https://github.com/vitest-dev/vitest/issues/7236
if (import.meta.env?.VITEST) {
return;
}
process.once(sig, (signal?: string | number, exitCode?: number) => {
runExitHandlers();
if (process.exitCode === undefined) {
Expand Down
10 changes: 8 additions & 2 deletions tests/command-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ export const runCommand = async (
cwd,
config,
logLevel = 'silent',
}: { cwd: string; config?: VivliostyleConfigSchema; logLevel?: LogLevel },
port,
}: {
cwd: string;
config?: VivliostyleConfigSchema;
logLevel?: LogLevel;
port?: number;
},
): Promise<ViteDevServer | void> => {
let inlineConfig = parseFlagsToInlineConfig(
['vivliostyle', command, ...args],
Expand All @@ -42,7 +48,7 @@ export const runCommand = async (
preview: setupPreviewParserProgram,
}[command],
);
inlineConfig = { ...inlineConfig, configData: config, cwd, logLevel };
inlineConfig = { ...inlineConfig, configData: config, cwd, logLevel, port };
return await { init, build, preview }[command](inlineConfig);
};

Expand Down
1 change: 1 addition & 0 deletions tests/pdf.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe('pdf output', () => {
['build', '-s', 'A4', '-o', '.vs-pdf/test.pdf', 'index.html'],
{
cwd: resolveFixture('wood'),
port: 23000,
},
);

Expand Down
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export default defineConfig({
NO_COLOR: 'true',
},
clearMocks: true,
pool: 'threads',
},
});

0 comments on commit 120edd3

Please sign in to comment.