Skip to content

Commit

Permalink
Update pnpm pack output parsing in __tests__/e2e.test.ts
Browse files Browse the repository at this point in the history
* Split the lines and match the line by the `preflight-...` pattern
* Remove the intermediary `pnpmPackOutput` variable and wrap the await expression in parentheses
* Use a more forgiving regex pattern for matching `preflight-...`
* Add error handling for missing tarball path in `pnpm pack` output
  • Loading branch information
karlhorky committed Nov 15, 2024
1 parent 35c1b5b commit f5c73a9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion __tests__/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ const fixturesTempDir = '__tests__/fixtures/__temp';
beforeAll(
async () => {
// Pack and install Preflight globally
const { stdout: pnpmPackTarballPath } = await execa`pnpm pack`;
const pnpmPackTarballPath = (await execa`pnpm pack`).stdout
.split('\n')
.find((line) => line.match(/^preflight-.*\.tgz$/));

if (!pnpmPackTarballPath) {
throw new Error('Failed to find the tarball path in `pnpm pack` output');

Check failure on line 15 in __tests__/e2e.test.ts

View workflow job for this annotation

GitHub Actions / ubuntu-latest: Build, lint, test

__tests__/e2e.test.ts

Error: Failed to find the tarball path in `pnpm pack` output ❯ __tests__/e2e.test.ts:15:13
}

await execa`pnpm add --global ${process.cwd()}/${pnpmPackTarballPath}`;

await pMap(
Expand Down

0 comments on commit f5c73a9

Please sign in to comment.