add ESM-safe os test helpers and tsconfig for tests

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2026-01-28 11:52:41 +01:00
parent 8a49a6ea9c
commit 3f7be6d97d
12 changed files with 86 additions and 31 deletions

30
__tests__/.helpers/os.ts Normal file
View File

@@ -0,0 +1,30 @@
/**
* Copyright 2025 actions-toolkit authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {jest} from '@jest/globals';
import os from 'os';
export const mockPlatform = (platform: NodeJS.Platform) => {
return jest.spyOn(os, 'platform').mockImplementation(() => platform);
};
export const mockArch = (arch: string) => {
return jest.spyOn(os, 'arch').mockImplementation(() => arch);
};
export const mockHomedir = (dir: string) => {
return jest.spyOn(os, 'homedir').mockImplementation(() => dir);
};