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

View File

@@ -19,9 +19,10 @@ import fs from 'fs';
import os from 'os';
import path from 'path';
import * as io from '@actions/io';
import osm = require('os');
import * as rimraf from 'rimraf';
import {mockHomedir} from '../.helpers/os';
import {Docker} from '../../src/docker/docker';
import {ConfigFile} from '../../src/types/docker/docker';
@@ -47,7 +48,7 @@ describe('configDir', () => {
});
it('returns default', async () => {
process.env.DOCKER_CONFIG = '';
jest.spyOn(osm, 'homedir').mockImplementation(() => path.join('/tmp', 'home'));
mockHomedir(path.join('/tmp', 'home'));
expect(Docker.configDir).toEqual(path.join('/tmp', 'home', '.docker'));
});
it('returns from env', async () => {

View File

@@ -19,7 +19,8 @@ import fs from 'fs';
import os from 'os';
import path from 'path';
import * as rimraf from 'rimraf';
import osm = require('os');
import {mockArch, mockPlatform} from '../.helpers/os';
import {Install, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install';
@@ -60,8 +61,8 @@ describe('download', () => {
[image('27.3.1'), 'win32'],
])(
'acquires %p of docker (%s)', async (source, platformOS) => {
jest.spyOn(osm, 'platform').mockImplementation(() => platformOS as NodeJS.Platform);
jest.spyOn(osm, 'arch').mockImplementation(() => 'x64');
mockPlatform(platformOS as NodeJS.Platform);
mockArch('x64');
const install = new Install({
source: source,
runDir: tmpDir