Skip to content

Commit

Permalink
test: Updating test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
rschristian committed Jun 7, 2022
1 parent 448c33f commit 8fef389
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/cli/tests/build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,14 @@ describe('preact build', () => {

// The tsconfig.json in the template covers the test directory,
// so TS will error out if it can't find even test-only module definitions
const oldCwd = process.cwd();
shell.cd(dir);
//shell.exec('npm i @types/enzyme@3.10.11 enzyme-adapter-preact-pure');
// Remove when https://github.com/preactjs/enzyme-adapter-preact-pure/issues/161 is resolved
shell.exec('rm tsconfig.json');

await expect(build(dir)).resolves.not.toThrow();
shell.cd(oldCwd);
});

it('should patch global location object', async () => {
Expand Down Expand Up @@ -358,14 +360,15 @@ describe('preact build', () => {
});

it('--invalid-arg', async () => {
let dir = await subject('minimal');
// @ts-ignore
const mockExit = jest.spyOn(process, 'exit').mockImplementation(() => {});
await expect(build(dir, { 'invalid-arg': false })).rejects.toEqual(
new Error('Invalid argument found.')
// Invalid arguments are caught by sade and it operates over process.argv,
// necessitating this (or a similar) approach.
const { code, stderr } = shell.exec(
`node ${join(process.cwd(), 'lib/index.js')} build --invalid-arg`
);
expect(stderr).toMatch(
"Invalid argument '--invalid-arg' passed to build."
);
expect(mockExit).toHaveBeenCalledWith(1);
mockExit.mockRestore();
expect(code).toBe(1);
});
});

Expand Down

0 comments on commit 8fef389

Please sign in to comment.