Skip to content

Commit

Permalink
build(setup.ts): update with new lib-pkg tools
Browse files Browse the repository at this point in the history
  • Loading branch information
Xunnamius committed Feb 22, 2021
1 parent 0282ede commit e77df0b
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions test/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,10 @@ export function protectedImportFactory(path: string) {

await withMockedExit(async ({ exitSpy }) => {
pkg = await isolatedImport(path);
if (params?.expectedExitCode !== undefined)
expect(exitSpy).toBeCalledWith(params?.expectedExitCode);
if (expect && params?.expectedExitCode)
expect(exitSpy).toBeCalledWith(params.expectedExitCode);
else if (!expect)
debug('WARNING: "expect" object not found, so exit check was skipped');
});

return pkg;
Expand Down Expand Up @@ -207,18 +209,6 @@ export async function withMockedOutput(
}
}

// TODO: XXX: make this into a separate (mock-output-exit) package
export async function withMockedOutputAndExit(
fn: (
spies: Parameters<Parameters<typeof withMockedOutput>[0]>[0] &
Parameters<Parameters<typeof withMockedExit>[0]>[0]
) => AnyVoid
) {
return withMockedExit(({ exitSpy }) =>
withMockedOutput((otherSpies) => fn({ ...otherSpies, exitSpy }))
);
}

// TODO: XXX: make this into a separate (run) package
// ! By default, does NOT reject on bad exit code (set reject: true to override)
export async function run(file: string, args?: string[], options?: execa.Options) {
Expand Down

0 comments on commit e77df0b

Please sign in to comment.