-
-
Notifications
You must be signed in to change notification settings - Fork 13
chore(deps): update dependencies and fix security vulnerabilities #396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5f7cdc8
0f66bd3
f060716
bbad697
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,7 +11,10 @@ import { actionTestString, actTestYmlPath } from './action.constants.js'; | |||||||||||||||||
| export const __filename = fileURLToPath(import.meta.url); | ||||||||||||||||||
| export const __dirname = path.dirname(__filename); | ||||||||||||||||||
|
|
||||||||||||||||||
| vi.mock('node:fs'); | ||||||||||||||||||
| vi.mock('node:fs', async () => { | ||||||||||||||||||
| const mockFs = await import('../__mocks__/node:fs.js'); | ||||||||||||||||||
| return mockFs; | ||||||||||||||||||
| }); | ||||||||||||||||||
| vi.mock('../src/logtask/index.js'); | ||||||||||||||||||
|
|
||||||||||||||||||
| let tempEnv: typeof process.env; | ||||||||||||||||||
|
|
@@ -31,8 +34,8 @@ describe('Action', () => { | |||||||||||||||||
| afterEach(() => { | ||||||||||||||||||
| vi.unstubAllEnvs(); | ||||||||||||||||||
| process.env = tempEnv; | ||||||||||||||||||
| // restore replaced property | ||||||||||||||||||
| vi.restoreAllMocks(); | ||||||||||||||||||
| // In vitest 4.x, we need to reset mocks to restore their original implementation | ||||||||||||||||||
| vi.resetAllMocks(); | ||||||||||||||||||
| }); | ||||||||||||||||||
|
|
||||||||||||||||||
| describe('test mocks work', () => { | ||||||||||||||||||
|
|
@@ -161,10 +164,43 @@ describe('Action', () => { | |||||||||||||||||
| }); | ||||||||||||||||||
|
|
||||||||||||||||||
| describe('stringify', () => { | ||||||||||||||||||
| beforeEach(() => { | ||||||||||||||||||
| // Reset YAML.stringify to ensure clean state | ||||||||||||||||||
| vi.restoreAllMocks(); | ||||||||||||||||||
| }); | ||||||||||||||||||
|
Comment on lines
+167
to
+170
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistent mock cleanup strategy This
The Apply this diff to use consistent mock cleanup: beforeEach(() => {
- // Reset YAML.stringify to ensure clean state
- vi.restoreAllMocks();
+ // Clear YAML.stringify mock history to ensure clean state
+ vi.clearAllMocks();
});📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| it('should stringify the action to YAML', async () => { | ||||||||||||||||||
| const { default: Action } = await import('../src/Action.js'); | ||||||||||||||||||
| const action = new Action(actTestYmlPath, mockLogTask); | ||||||||||||||||||
|
|
||||||||||||||||||
| // Mock YAML.stringify to test the method behavior without actual serialization | ||||||||||||||||||
| // (Action objects with LogTask can't be serialized due to function properties) | ||||||||||||||||||
| const mockYamlOutput = `name: Test Action | ||||||||||||||||||
| author: Test Author | ||||||||||||||||||
| description: Test Description | ||||||||||||||||||
| branding: | ||||||||||||||||||
| color: white | ||||||||||||||||||
| icon: activity | ||||||||||||||||||
| inputs: | ||||||||||||||||||
| input1: | ||||||||||||||||||
| description: Test Input 1 | ||||||||||||||||||
| required: true | ||||||||||||||||||
| default: default1 | ||||||||||||||||||
| input2: | ||||||||||||||||||
| description: Test Input 2 | ||||||||||||||||||
| outputs: | ||||||||||||||||||
| output1: | ||||||||||||||||||
| description: Test Output 1 | ||||||||||||||||||
| runs: | ||||||||||||||||||
| using: container | ||||||||||||||||||
| image: test-image | ||||||||||||||||||
| main: test-main | ||||||||||||||||||
| pre: test-pre | ||||||||||||||||||
| `; | ||||||||||||||||||
| vi.spyOn(YAML, 'stringify').mockReturnValue(mockYamlOutput); | ||||||||||||||||||
|
|
||||||||||||||||||
| const yamlString = action.stringify(); | ||||||||||||||||||
|
|
||||||||||||||||||
| expect(yamlString).toContain('name: Test Action'); | ||||||||||||||||||
| expect(yamlString).toContain('author: Test Author'); | ||||||||||||||||||
| expect(yamlString).toContain('description: Test Description'); | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -23,7 +23,10 @@ vi.mock('@actions/core'); | |||||||
|
|
||||||||
| vi.mock('../src/readme-editor.js'); | ||||||||
| // Mocking required objects and functions | ||||||||
| vi.mock('node:fs'); | ||||||||
| vi.mock('node:fs', async () => { | ||||||||
| const mockFs = await import('../__mocks__/node:fs.js'); | ||||||||
| return mockFs; | ||||||||
| }); | ||||||||
| describe('ReadmeGenerator', () => { | ||||||||
| let mockInputs: Inputs; | ||||||||
| let mockLogTask: LogTask; | ||||||||
|
|
@@ -49,7 +52,8 @@ describe('ReadmeGenerator', () => { | |||||||
| }); | ||||||||
|
|
||||||||
| afterEach(() => { | ||||||||
| vi.restoreAllMocks(); | ||||||||
| // In vitest 4.x, use resetAllMocks to clear mock history | ||||||||
|
||||||||
| // In vitest 4.x, use resetAllMocks to clear mock history | |
| // resetAllMocks() clears mock history and resets implementations in all Vitest versions. | |
| // If you need to restore original (non-mocked) implementations, use restoreAllMocks() instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is misleading.
resetAllMocks()clears mock history and resets implementation, butrestoreAllMocks()is what restores original implementations. In Vitest 4.x, if the intent is to restore original implementations (not just reset state),restoreAllMocks()should still be used.