Skip to content

Commit

Permalink
test: add integration test for --clean/--no-clean options
Browse files Browse the repository at this point in the history
  • Loading branch information
ZauberNerd committed Dec 13, 2020
1 parent 432ab6c commit 6f5f301
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/__tests__/_integration-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { execSync } from 'child_process';
import { existsSync } from 'fs';

// eslint-disable-next-line node/no-missing-require
const pathToBin = require.resolve('canarist/dist/bin.js');
Expand Down Expand Up @@ -40,10 +41,29 @@ describe('integration tests', () => {

expect(exitCode).toBe(0);

const [, folder] =
stdout.match(/\[canarist\] cloning "[^]+" into "([^"]+)"/) || [];
expect(existsSync(folder)).toBe(false);

expect(stdout).toContain('[canarist] executing command "yarn build"');
expect(stdout).toContain('[canarist] executing command "yarn test"');
expect(stdout).toContain('[canarist] finished successfully!');
});
it('should keep the target folder if --no-clean is set', (): void => {
const { exitCode, stdout } = canarist(
`-r [${repository} -d folder-a -b monorepo-a -c]`,
`-r [${repository} -d folder-b -b monorepo-b -c]`,
`--no-clean`
);

expect(exitCode).toBe(0);

const [, folder] =
stdout.match(/\[canarist\] cloning "[^]+" into "([^"]+)"/) || [];
expect(existsSync(folder)).toBe(true);

expect(stdout).toContain('[canarist] finished successfully!');
});

it('should fail when a command fails', (): void => {
const { exitCode, stdout, stderr } = canarist(
Expand All @@ -53,6 +73,10 @@ describe('integration tests', () => {

expect(exitCode).toBe(1);

const [, folder] =
stdout.match(/\[canarist\] cloning "[^]+" into "([^"]+)"/) || [];
expect(existsSync(folder)).toBe(false);

expect(stdout).toContain(
'[canarist] executing command "yarn run not-available"'
);
Expand Down

0 comments on commit 6f5f301

Please sign in to comment.