Skip to content

Commit

Permalink
chore: fix hooks executor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
awsluja committed Jul 21, 2023
1 parent 50f7c87 commit 39adc04
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,16 @@ describe('hooksExecutioner tests', () => {
test('skip Hooks test', async () => {
mockSkipHooks.mockRestore();

const orgSkipHooksExist = fs.existsSync(skipHooksFilePath);

fs.ensureFileSync(skipHooksFilePath);
// skip hooks file exists so no execa calls should be made
process.env.AMPLIFY_CLI_DISABLE_SCRIPTING_FEATURES = 'true';
// skip hooks flag exists so no execa calls should be made
await executeHooks(HooksMeta.getInstance({ command: 'push', plugin: 'core' } as CommandLineInput, 'pre'));
expect(execa).toHaveBeenCalledTimes(0);

fs.removeSync(skipHooksFilePath);
// skip hooks file does not exists so execa calls should be made
delete process.env.AMPLIFY_CLI_DISABLE_SCRIPTING_FEATURES;
// skip hooks flag does not exist so execa calls should be made
await executeHooks(HooksMeta.getInstance({ command: 'push', plugin: 'core' } as CommandLineInput, 'pre'));
expect(execa).not.toHaveBeenCalledTimes(0);

// restoring the original state of skip hooks file
if (!orgSkipHooksExist) fs.removeSync(skipHooksFilePath);
else fs.ensureFileSync(skipHooksFilePath);
mockSkipHooks = jest.spyOn(skipHooksModule, 'skipHooks');
});

Expand Down

0 comments on commit 39adc04

Please sign in to comment.