mirror of
https://github.com/actions/setup-dotnet.git
synced 2026-07-20 18:01:10 +00:00
Migrate to ESM and upgrade dependencies (#752)
* Migrate to ESM and upgrade dependencies * Address review: use type-only import for QualityOptions * update version to 6.0.0 in package.json and package-lock.json * Add ESM migration note to README for V6 * Update test imports for ESM and clean up devDependencies (ts-node, @types/jest) * Pin @types/node to 24.x and refine tsconfig/README wording
This commit is contained in:
@@ -1,11 +1,29 @@
|
||||
import * as cache from '@actions/cache';
|
||||
import * as exec from '@actions/exec';
|
||||
import {
|
||||
afterEach,
|
||||
beforeAll,
|
||||
beforeEach,
|
||||
describe,
|
||||
expect,
|
||||
it,
|
||||
jest
|
||||
} from '@jest/globals';
|
||||
|
||||
import {getNuGetFolderPath, isCacheFeatureAvailable} from '../src/cache-utils';
|
||||
jest.unstable_mockModule('@actions/cache', () => ({
|
||||
isFeatureAvailable: jest.fn()
|
||||
}));
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
warning: jest.fn(),
|
||||
info: jest.fn(),
|
||||
debug: jest.fn()
|
||||
}));
|
||||
jest.unstable_mockModule('@actions/exec', () => ({
|
||||
getExecOutput: jest.fn()
|
||||
}));
|
||||
|
||||
jest.mock('@actions/cache');
|
||||
jest.mock('@actions/core');
|
||||
jest.mock('@actions/exec');
|
||||
const cache = await import('@actions/cache');
|
||||
const exec = await import('@actions/exec');
|
||||
const {getNuGetFolderPath, isCacheFeatureAvailable} =
|
||||
await import('../src/cache-utils.js');
|
||||
|
||||
describe('cache-utils tests', () => {
|
||||
describe('getNuGetFolderPath()', () => {
|
||||
@@ -104,9 +122,15 @@ Options:
|
||||
url => {
|
||||
// Save & Restore env
|
||||
let serverUrlEnv: string | undefined;
|
||||
beforeAll(() => (serverUrlEnv = process.env['GITHUB_SERVER_URL']));
|
||||
beforeEach(() => (process.env['GITHUB_SERVER_URL'] = url));
|
||||
afterEach(() => (process.env['GITHUB_SERVER_URL'] = serverUrlEnv));
|
||||
beforeAll(() => {
|
||||
serverUrlEnv = process.env['GITHUB_SERVER_URL'];
|
||||
});
|
||||
beforeEach(() => {
|
||||
process.env['GITHUB_SERVER_URL'] = url;
|
||||
});
|
||||
afterEach(() => {
|
||||
process.env['GITHUB_SERVER_URL'] = serverUrlEnv;
|
||||
});
|
||||
|
||||
it('returns true when cache.isFeatureAvailable() === true', () => {
|
||||
jest.mocked(cache.isFeatureAvailable).mockReturnValue(true);
|
||||
|
||||
Reference in New Issue
Block a user