mirror of
https://github.com/Azure/k8s-set-context.git
synced 2026-06-28 10:19:27 +08:00
Migrate to ESM with esbuild, vitest (#227)
* Migrate to ESM, esbuild, vitest, and update actions/* to latest - Update @actions/core to 3.x, @actions/exec to 3.x, @actions/io to 3.x - Replace @vercel/ncc + babel with esbuild (build.mjs) targeting Node 20 ESM - Replace jest/babel-jest/ts-jest with vitest and @vitest/coverage-v8 - Update tsconfig to NodeNext module resolution with strict mode - Add explicit .js extensions to all relative imports (NodeNext requirement) - Fix implicit any index signatures in parseCluster and parseMethod - Migrate all test files from jest to vi.mock/vi.mocked APIs - Fix ESM module spying limitations using vi.mock() at module level - Fix env var test pollution in default.test.ts with afterEach cleanup * remove build.mjs and update build script * update pkg lock * update pkg lock
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import * as actions from '@actions/exec'
|
||||
import {vi, describe, test, it, expect, beforeEach} from 'vitest'
|
||||
import * as io from '@actions/io'
|
||||
import {getRequiredInputError} from '../../tests/util'
|
||||
import {getArcKubeconfig, KUBECONFIG_LOCATION} from './arc'
|
||||
import * as az from './azCommands'
|
||||
import {getRequiredInputError} from '../../tests/util.js'
|
||||
import {getArcKubeconfig, KUBECONFIG_LOCATION} from './arc.js'
|
||||
import * as az from './azCommands.js'
|
||||
|
||||
vi.mock('@actions/io')
|
||||
vi.mock('./azCommands.js')
|
||||
|
||||
describe('Arc kubeconfig', () => {
|
||||
test('it throws error without resource group', async () => {
|
||||
@@ -28,11 +31,11 @@ describe('Arc kubeconfig', () => {
|
||||
process.env['INPUT_RESOURCE-GROUP'] = group
|
||||
process.env['INPUT_CLUSTER-NAME'] = name
|
||||
|
||||
jest.spyOn(io, 'which').mockImplementation(async () => path)
|
||||
jest.spyOn(az, 'runAzCliCommand').mockImplementation(async () => {})
|
||||
jest
|
||||
.spyOn(az, 'runAzKubeconfigCommandBlocking')
|
||||
.mockImplementation(async () => kubeconfig)
|
||||
vi.mocked(io.which).mockResolvedValue(path)
|
||||
vi.mocked(az.runAzCliCommand).mockResolvedValue(undefined)
|
||||
vi.mocked(az.runAzKubeconfigCommandBlocking).mockResolvedValue(
|
||||
kubeconfig
|
||||
)
|
||||
})
|
||||
|
||||
it('throws an error without method', async () => {
|
||||
|
||||
Reference in New Issue
Block a user