Skip to content

Commit 48503ae

Browse files
committed
fixed broken unit tests. mock for execa was undefined before.
1 parent e627bed commit 48503ae

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/__tests__/github.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
jest.mock('execa');
1+
jest.mock('execa', () => ({
2+
__esModule: true,
3+
execa: jest.fn(),
4+
}));
25

3-
import { execa } from 'execa';
46
import {
57
sanitizeRepoName,
68
checkGhAuth,
79
repoExists,
810
createRepo,
911
} from '../github.js';
1012

11-
const mockExeca = execa as jest.MockedFunction<typeof execa>;
13+
const { execa: mockExeca } = require('execa');
1214

1315
describe('sanitizeRepoName', () => {
1416
it('returns lowercase name with invalid chars replaced by hyphen', () => {
@@ -93,7 +95,7 @@ describe('checkGhAuth', () => {
9395
stdout: ' octocat ',
9496
stderr: '',
9597
exitCode: 0,
96-
} as Awaited<ReturnType<typeof execa>>);
98+
});
9799

98100
const result = await checkGhAuth();
99101

@@ -135,9 +137,7 @@ describe('createRepo', () => {
135137

136138
beforeEach(() => {
137139
mockExeca.mockReset();
138-
mockExeca.mockResolvedValue({ stdout: '', stderr: '', exitCode: 0 } as Awaited<
139-
ReturnType<typeof execa>
140-
>);
140+
mockExeca.mockResolvedValue({ stdout: '', stderr: '', exitCode: 0 });
141141
});
142142

143143
it('calls gh repo create with expected args and returns repo URL', async () => {

0 commit comments

Comments
 (0)