Skip to content

Commit

Permalink
fix: catch errors in async artifact tests
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber committed Jun 7, 2024
1 parent ef8a796 commit d98af76
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ $ pnpm bench --minifier <minifier> <artifact>

Example:
```
$ pnpm bench --minifier esbuild vue
$ pnpm bench --minifier esbuild --artifact vue
```

### Benchmark all artifacts & minifiers
Expand Down
4 changes: 2 additions & 2 deletions packages/artifacts/utils/artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ export class Artifact {
code = test.preprocess(code);
}

const codeExport = requireString(code);
const privateConsole = blockConsole();
try {
test.run(codeExport);
const codeExport = requireString(code);
await test.run(codeExport);
} finally {
privateConsole.restore();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/artifacts/utils/define-test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type Test<T = unknown> = {
preprocess?: (code: string) => string;
run: (exports: T) => void;
run: (exports: T) => void | Promise<void>;
};

export const defineTest = <T>(
Expand Down

0 comments on commit d98af76

Please sign in to comment.