Skip to content

Commit 04a3199

Browse files
Copilotsetchy
andcommitted
Changes before error encountered
Co-authored-by: setchy <[email protected]>
1 parent d0763ec commit 04a3199

File tree

3 files changed

+152
-6
lines changed

3 files changed

+152
-6
lines changed

jest.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const config: Config = {
1010
// Force CommonJS build for http adapter to be available.
1111
// via https://github.com/axios/axios/issues/5101#issuecomment-1276572468
1212
'^axios$': require.resolve('axios'),
13+
// Mock ES modules that cause issues with Jest
14+
'^@octokit/core$': '<rootDir>/src/renderer/__helpers__/octokit.mock.ts',
15+
'^@octokit/plugin-paginate-rest$': '<rootDir>/src/renderer/__helpers__/octokit.mock.ts',
1316
},
1417
modulePathIgnorePatterns: ['<rootDir>/build', '<rootDir>/node_modules'],
1518
};

pnpm-lock.yaml

Lines changed: 112 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Mock implementation for Octokit to work with Jest
2+
export class Octokit {
3+
auth?: string;
4+
baseUrl?: string;
5+
6+
constructor(options?: { auth?: string; baseUrl?: string }) {
7+
this.auth = options?.auth;
8+
this.baseUrl = options?.baseUrl;
9+
}
10+
11+
static plugin(...plugins: any[]) {
12+
return MockOctokit;
13+
}
14+
15+
request = jest.fn().mockResolvedValue({
16+
data: {},
17+
status: 200,
18+
headers: {},
19+
url: 'mock-url'
20+
});
21+
22+
graphql = jest.fn().mockResolvedValue({});
23+
24+
paginate = jest.fn().mockResolvedValue([]);
25+
}
26+
27+
class MockOctokit extends Octokit {
28+
constructor(options?: any) {
29+
super(options);
30+
}
31+
}
32+
33+
export const paginateRest = {
34+
paginate: jest.fn().mockResolvedValue([]),
35+
};
36+
37+
export default Octokit;

0 commit comments

Comments
 (0)