diff --git a/jest.config.cjs b/jest.config.cjs index 8f5c5b2c..59ffa5b3 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -3,6 +3,7 @@ module.exports = { testEnvironment: 'node', extensionsToTreatAsEsm: ['.ts', '.mts'], coveragePathIgnorePatterns: ['\\.mock\\.ts$'], + setupFilesAfterEnv: ['/jest.setup.ts'], moduleFileExtensions: ['ts', 'mts', 'tsx', 'js', 'mjs', 'jsx', 'json', 'node'], testRegex: '(/(__tests__|e2e)/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?|mts)$', transform: { diff --git a/jest.setup.ts b/jest.setup.ts new file mode 100644 index 00000000..d0198290 --- /dev/null +++ b/jest.setup.ts @@ -0,0 +1,3 @@ +beforeEach(() => { + process.env.SHEPHERD_GITHUB_ENTERPRISE_URL = 'https://api.github.com'; +}); diff --git a/src/adapters/git.test.ts b/src/adapters/git.test.ts index 164926bc..b039f2c9 100644 --- a/src/adapters/git.test.ts +++ b/src/adapters/git.test.ts @@ -7,6 +7,14 @@ jest.mock('simple-git'); jest.mock('fs-extra'); class TestGitAdapter extends GitAdapter { + // @ts-ignore + createIssue(repo: IRepo): Promise { + return Promise.resolve(''); + } + // @ts-ignore + updateIssue(repo: IRepo, issueNumber: number): Promise { + return Promise.resolve(); + } // @ts-ignore getCandidateRepos(onRetry: RetryMethod): Promise { return Promise.resolve([]); diff --git a/src/adapters/github.test.ts b/src/adapters/github.test.ts index 440df492..71d08ed6 100644 --- a/src/adapters/github.test.ts +++ b/src/adapters/github.test.ts @@ -268,17 +268,19 @@ describe('GithubAdapter', () => { it('returns the SSH URL, when not given a protocol', () => { delete process.env.SHEPHERD_GITHUB_PROTOCOL; - expect(adapter['getRepositoryUrl'](repo)).toBe('git@github.com:NerdWallet/shepherd.git'); + expect(adapter['getRepositoryUrl'](repo)).toBe('git@api.github.com:NerdWallet/shepherd.git'); }); it('returns the SSH URL, when given protocol=ssh', () => { process.env.SHEPHERD_GITHUB_PROTOCOL = 'ssh'; - expect(adapter['getRepositoryUrl'](repo)).toBe('git@github.com:NerdWallet/shepherd.git'); + expect(adapter['getRepositoryUrl'](repo)).toBe('git@api.github.com:NerdWallet/shepherd.git'); }); it('returns the HTTPS URL when given protocol=https', () => { process.env.SHEPHERD_GITHUB_PROTOCOL = 'https'; - expect(adapter['getRepositoryUrl'](repo)).toBe('https://github.com/NerdWallet/shepherd.git'); + expect(adapter['getRepositoryUrl'](repo)).toBe( + 'https://api.github.com/NerdWallet/shepherd.git' + ); }); it('throws on unexpected protocols', () => {