Skip to content

Commit

Permalink
fix: Wait for formatter job finish after type tests generated
Browse files Browse the repository at this point in the history
  • Loading branch information
lasuillard committed Jun 30, 2024
1 parent c258435 commit 993dcfb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
20 changes: 12 additions & 8 deletions tests/_helpers/typechecks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,23 @@ it('${item.testId}', () => {
return filepath;
}

export function generateAllTests() {
export async function generateAllTests() {
const dir = path.join(__dirname, "..", "__typechecks__");
if (!fs.existsSync(dir)) fs.mkdirSync(dir);

for (const spec of filesToCreate) {
const filepath = generateTest(dir, spec);
exec(`yarn run biome check --write ${filepath}`, (err, stdout, stderr) => {
if (err) {
console.error(stderr);
process.exit(1);
}

console.log(stdout);
await new Promise((resolve, reject) => {
exec(
`yarn run biome check --write --unsafe ${filepath}`,
(err, stdout, stderr) => {
if (err) {
console.error(stderr);
reject(err);
}
resolve(stdout);
},
);
});
}
}
4 changes: 2 additions & 2 deletions tests/setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { afterAll } from "vitest";
import { generateAllTests } from "./_helpers/typechecks";

afterAll(() => {
generateAllTests();
afterAll(async () => {
await generateAllTests();
});

0 comments on commit 993dcfb

Please sign in to comment.