Skip to content

Commit

Permalink
minor test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ecraig12345 committed May 4, 2023
1 parent 8537c4f commit 25f7eac
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/__e2e__/change.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ describe('change command', () => {
makeMonorepoChanges(repo);

const changePromise = change({ path: repo.rootPath, branch: defaultBranchName } as BeachballOptions);
await waitForPrompt();

// use custom values for first package
expect(logs.mocks.log).toHaveBeenLastCalledWith('Please describe the changes for: pkg-1');
Expand Down Expand Up @@ -212,6 +213,7 @@ describe('change command', () => {
branch: defaultBranchName,
groupChanges: true,
} as BeachballOptions);
await waitForPrompt();

// use custom values for first package
expect(logs.mocks.log).toHaveBeenLastCalledWith('Please describe the changes for: pkg-1');
Expand Down Expand Up @@ -242,6 +244,7 @@ describe('change command', () => {
const repo = repositoryFactory.cloneRepository();
makeMonorepoChanges(repo);

// custom prompt for different packages (only truly doable here because elsewhere it uses combinedOptions)
mockBeachballOptions = {
changeFilePrompt: {
changePrompt: (defaultPrompt, pkg) => {
Expand Down Expand Up @@ -284,6 +287,4 @@ describe('change command', () => {
expect.objectContaining({ packageName: 'pkg-2', type: 'patch', comment: 'commit 2', custom: 'stuff' }),
]);
});

// custom prompt for different packages (only truly doable here because elsewhere it uses combinedOptions)
});
6 changes: 2 additions & 4 deletions src/__e2e__/publishRegistry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('publish command (registry)', () => {
let repositoryFactory: RepositoryFactory | undefined;

// show error logs for these tests
const logs = initMockLogs(['error']);
const logs = initMockLogs({ alsoLog: ['error'] });

function getOptions(repo: Repository, overrides: Partial<BeachballOptions>): BeachballOptions {
return {
Expand Down Expand Up @@ -177,8 +177,6 @@ describe('publish command (registry)', () => {
);

await expect(publishPromise).rejects.toThrow();
expect(
logs.mocks.log.mock.calls.some(([arg0]) => typeof arg0 === 'string' && arg0.includes('Retrying... (3/3)'))
).toBeTruthy();
expect(logs.getMockLines('log')).toMatch('Retrying... (3/3)');
});
});
9 changes: 8 additions & 1 deletion src/__fixtures__/repository.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from 'path';
import * as fs from 'fs-extra';
import { tmpdir } from './tmpdir';
import { git } from 'workspace-tools';
import { defaultBranchName, defaultRemoteName, setDefaultBranchName } from './gitDefaults';
import { tmpdir } from './tmpdir';

/**
* Represents a git repository.
Expand Down Expand Up @@ -72,6 +72,13 @@ ${gitResult.stderr.toString()}`);
return gitResult;
}

/** Log the results of a git command to non-wrapped console.log (for debugging) */
async gitConsoleLog(args: string[]) {
realConsole.log(`$ git ${args.join(' ')}`);
const res = await execa('git', args, { cwd: this.rootPath, all: true, reject: false });
realConsole.log(res.all);
}

/**
* Create (or update) and stage a file, creating the intermediate directories if necessary.
* Automatically uses root path; do not pass absolute paths here.
Expand Down

0 comments on commit 25f7eac

Please sign in to comment.