Skip to content

Commit

Permalink
🧪 Run end-to-end tests concurrently but with longer timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
fwkoch committed Apr 10, 2024
1 parent 36785fa commit cec2d31
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .changeset/ten-rockets-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'mystmd': patch
---

Add end-to-end tests for various DOIs
52 changes: 28 additions & 24 deletions packages/mystmd/tests/endToEnd.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,32 @@ function resolve(relative: string) {
return path.resolve(__dirname, relative);
}

describe('End-to-end cli export tests', () => {
const cases = loadCases('exports.yml');
test.each(cases.map((c): [string, TestCase] => [c.title, c]))(
'%s',
async (_, { cwd, command, outputs }) => {
// Clean expected outputs if they already exist
await Promise.all(
outputs.map(async (output) => {
if (fs.existsSync(resolve(output.path))) {
await exec(`rm ${resolve(output.path)}`, { cwd: resolve(cwd) });
}
}),
);
// Run CLI command
await exec(command, { cwd: resolve(cwd) });
// Expect correct output
outputs.forEach((output) => {
expect(fs.existsSync(resolve(output.path))).toBeTruthy();
expect(fs.readFileSync(resolve(output.path), { encoding: 'utf-8' })).toEqual(
fs.readFileSync(resolve(output.content), { encoding: 'utf-8' }),
describe.concurrent(
'End-to-end cli export tests',
() => {
const cases = loadCases('exports.yml');
test.each(cases.map((c): [string, TestCase] => [c.title, c]))(
'%s',
async (_, { cwd, command, outputs }) => {
// Clean expected outputs if they already exist
await Promise.all(
outputs.map(async (output) => {
if (fs.existsSync(resolve(output.path))) {
await exec(`rm ${resolve(output.path)}`, { cwd: resolve(cwd) });
}
}),
);
});
},
);
});
// Run CLI command
await exec(command, { cwd: resolve(cwd) });
// Expect correct output
outputs.forEach((output) => {
expect(fs.existsSync(resolve(output.path))).toBeTruthy();
expect(fs.readFileSync(resolve(output.path), { encoding: 'utf-8' })).toEqual(
fs.readFileSync(resolve(output.content), { encoding: 'utf-8' }),
);
});
},
);
},
{ timeout: 15000 },
);

0 comments on commit cec2d31

Please sign in to comment.