wip: replace jest with vitest

This commit is contained in:
JM Faircloth 2024-03-08 16:57:50 -06:00
parent b379e88781
commit fcac78057e
22 changed files with 2182 additions and 78 deletions

View file

@ -1,5 +1,7 @@
jest.mock('@actions/core');
jest.mock('@actions/core/lib/command');
import { vi, describe, test, expect } from 'vitest';
vi.mock('@actions/core');
vi.mock('@actions/core/lib/command');
import * as core from '@actions/core';
import got from 'got';
@ -102,7 +104,7 @@ describe('authenticate with approle', () => {
});
beforeEach(() => {
jest.resetAllMocks();
vi.resetAllMocks();
when(core.getInput)
.calledWith('method', expect.anything())

View file

@ -1,5 +1,7 @@
jest.mock('@actions/core');
jest.mock('@actions/core/lib/command');
import { vi, describe, test, expect } from 'vitest';
vi.mock('@actions/core');
vi.mock('@actions/core/lib/command');
import * as core from '@actions/core';
import got from 'got';
@ -107,7 +109,7 @@ describe('integration', () => {
});
beforeEach(() => {
jest.resetAllMocks();
vi.resetAllMocks();
when(core.getInput)
.calledWith('url', expect.anything())

View file

@ -1,3 +0,0 @@
module.exports = {
verbose: true
};

View file

@ -1,12 +1,14 @@
jest.mock('@actions/core');
jest.mock('@actions/core/lib/command');
import { vi, describe, test, expect } from 'vitest';
vi.mock('@actions/core');
vi.mock('@actions/core/lib/command');
import * as core from '@actions/core';
import rsasign from 'jsrsasign';
import {
privateRsaKey,
privateRsaKeyBase64,
publicRsaKey
} from './rsa_keys.js');
} from './rsa_keys.js';
import got from 'got';
import { when } from 'jest-when'
@ -139,7 +141,7 @@ describe('jwt auth', () => {
describe('authenticate with private key', () => {
beforeEach(() => {
jest.resetAllMocks();
vi.resetAllMocks();
when(core.getInput)
.calledWith('url', expect.anything())
@ -189,7 +191,7 @@ describe('jwt auth', () => {
})
beforeEach(() => {
jest.resetAllMocks();
vi.resetAllMocks();
when(core.getInput)
.calledWith('url', expect.anything())

View file

@ -1,5 +1,7 @@
jest.mock('@actions/core');
jest.mock('@actions/core/lib/command');
import { vi, describe, test, expect } from 'vitest';
vi.mock('@actions/core');
vi.mock('@actions/core/lib/command');
import * as core from '@actions/core';
import got from 'got';

View file

@ -0,0 +1,8 @@
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
// required to make jest-when work with vitest
globals: true,
},
})

View file

@ -1,3 +1,5 @@
import { describe, test, expect } from 'vitest';
describe('e2e-tls', () => {
it('verify', () => {
expect(process.env.SECRET).toBe("SUPERSECRET");

View file

@ -1,3 +1,5 @@
import { describe, test, expect } from 'vitest';
describe('e2e', () => {
it('verify', () => {
expect(process.env.SECRET).toBe("SUPERSECRET");

View file

@ -1,3 +0,0 @@
module.exports = {
verbose: true
};

View file

@ -0,0 +1,8 @@
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
// required to make jest-when work with vitest
globals: true,
},
})

View file

@ -1,5 +1,7 @@
jest.mock('@actions/core');
jest.mock('@actions/core/lib/command');
import { vi, describe, test, expect } from 'vitest';
vi.mock('@actions/core');
vi.mock('@actions/core/lib/command');
import * as core from '@actions/core';
import got from 'got';
@ -41,7 +43,7 @@ describe('integration', () => {
});
beforeEach(() => {
jest.resetAllMocks();
vi.resetAllMocks();
when(core.getInput)
.calledWith('url', expect.anything())
@ -238,7 +240,7 @@ describe('authenticate with approle', () => {
});
beforeEach(() => {
jest.resetAllMocks();
vi.resetAllMocks();
when(core.getInput)
.calledWith('method', expect.anything())

View file

@ -1,3 +0,0 @@
module.exports = {
verbose: true
};

View file

@ -0,0 +1,8 @@
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
// required to make jest-when work with vitest
globals: true,
},
})