mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2026-05-31 00:12:03 +08:00
* chore: merge all Dependabot dependency updates with fixes - Update @actions/core/exec/github/io to v3/v9 (ESM-only) - Update @eslint/js to v10, @typescript-eslint/* to 8.58, eslint-plugin-jest/prettier - Update jest 29→30, typescript 5.8→6.0, @types/jest/node, prettier, rimraf, ts-jest - Update lodash 4.17→4.18 (yarn.lock only) - Add CJS test stubs for ESM-only @actions/* packages - Update tsconfig.json: target es2022, add types for node+jest - Update jest.config.js: moduleNameMapper for stubs, remove jest-circus runner - Fix new lint rules: preserve-caught-error and no-useless-assignment Agent-Logs-Url: https://github.com/JamesIves/github-pages-deploy-action/sessions/2a6d68c0-eab5-4c98-a927-2525b124ca87 Co-authored-by: JamesIves <10888441+JamesIves@users.noreply.github.com> * refactor: convert project to proper ESM - package.json: add "type": "module" for ESM runtime + nodenext compilation - tsconfig.json: module/moduleResolution → nodenext (ESM output with .js extensions) - src/*.ts: add .js extensions to all relative imports - __tests__/*.test.ts: add .js to relative imports, remove jest.mock() factories for @actions/* - jest.config.js → jest.config.cjs: CJS jest config, moduleNameMapper strips .js for ts-jest - __mocks__/@actions/*.js + package.json: proper Jest manual mocks (CJS, with functional implementations for integration tests) replacing __tests__/stubs/ workaround - eslint.config.mjs: ignore __mocks__/** instead of __tests__/stubs/** Agent-Logs-Url: https://github.com/JamesIves/github-pages-deploy-action/sessions/c73b8f61-87f7-4eab-8e99-d363a69f6e66 Co-authored-by: JamesIves <10888441+JamesIves@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JamesIves <10888441+JamesIves@users.noreply.github.com>
36 lines
958 B
TypeScript
36 lines
958 B
TypeScript
import {TestFlag} from '../src/constants.js'
|
|
import {execute} from '../src/execute.js'
|
|
import {generateWorktree} from '../src/worktree.js'
|
|
|
|
jest.mock('../src/execute', () => ({
|
|
__esModule: true,
|
|
execute: jest.fn(() => ({stdout: '', stderr: ''}))
|
|
}))
|
|
|
|
describe('generateWorktree', () => {
|
|
it('should catch when a function throws an error', async () => {
|
|
;(execute as jest.Mock).mockImplementationOnce(() => {
|
|
throw new Error('Mocked throw')
|
|
})
|
|
try {
|
|
await generateWorktree(
|
|
{
|
|
hostname: 'github.com',
|
|
workspace: 'somewhere',
|
|
singleCommit: false,
|
|
branch: 'gh-pages',
|
|
folder: '',
|
|
silent: true,
|
|
isTest: TestFlag.HAS_CHANGED_FILES
|
|
},
|
|
'worktree',
|
|
true
|
|
)
|
|
} catch (error) {
|
|
expect(error instanceof Error && error.message).toBe(
|
|
'There was an error creating the worktree: Mocked throw ❌'
|
|
)
|
|
}
|
|
})
|
|
})
|