refactor: replace jest with vitest
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
module.exports = {
|
||||
preset: "ts-jest",
|
||||
testEnvironment: "node",
|
||||
roots: ["<rootDir>/src"],
|
||||
testMatch: ["**/*.spec.ts"],
|
||||
moduleNameMapper: {
|
||||
"^@actions/core$": "<rootDir>/src/__mocks__/actions-core.ts",
|
||||
},
|
||||
transform: {
|
||||
"^.+\\.ts$": "ts-jest",
|
||||
},
|
||||
moduleFileExtensions: ["ts", "js", "json"],
|
||||
};
|
||||
Generated
+1103
-4020
File diff suppressed because it is too large
Load Diff
+4
-5
@@ -5,20 +5,19 @@
|
||||
"scripts": {
|
||||
"typecheck": "tsc --noEmit",
|
||||
"build": "rolldown -c",
|
||||
"test": "jest",
|
||||
"test": "vitest",
|
||||
"format": "oxfmt --write src/**/*.ts"
|
||||
},
|
||||
"author": "Timo Behrendt <t.behrendt@t00n.de>",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/conventional-commits-parser": "5.0.2",
|
||||
"@types/jest": "30.0.0",
|
||||
"@types/node": "24.13.2",
|
||||
"jest": "30.4.2",
|
||||
"@vitest/coverage-v8": "4.1.10",
|
||||
"oxfmt": "0.59.0",
|
||||
"rolldown": "1.2.0",
|
||||
"ts-jest": "29.4.11",
|
||||
"typescript": "5.9.3"
|
||||
"typescript": "5.9.3",
|
||||
"vitest": "4.1.10"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": "3.0.1",
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
export const getInput = jest.fn(() => "");
|
||||
export const info = jest.fn();
|
||||
export const warning = jest.fn();
|
||||
export const setOutput = jest.fn();
|
||||
export const setFailed = jest.fn();
|
||||
+12
-12
@@ -1,22 +1,24 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi, type MockedFunction } from "vitest";
|
||||
|
||||
import {
|
||||
IncrementType,
|
||||
Tag,
|
||||
GitService,
|
||||
CoreService,
|
||||
ConventionalCommitAnalyzer,
|
||||
TagService,
|
||||
TagIncrementer,
|
||||
LocalGitService,
|
||||
CoreService,
|
||||
GitService,
|
||||
IncrementType,
|
||||
LocalCoreService,
|
||||
LocalGitService,
|
||||
Tag,
|
||||
TagIncrementer,
|
||||
TagService,
|
||||
} from "./main";
|
||||
|
||||
// Mock child_process.execSync
|
||||
jest.mock("child_process", () => ({
|
||||
execSync: jest.fn(),
|
||||
vi.mock("child_process", () => ({
|
||||
execSync: vi.fn(),
|
||||
}));
|
||||
|
||||
import { execSync } from "child_process";
|
||||
const mockExecSync = execSync as jest.MockedFunction<typeof execSync>;
|
||||
const mockExecSync = execSync as MockedFunction<typeof execSync>;
|
||||
|
||||
// Mock interfaces for testing
|
||||
class MockGitService implements GitService {
|
||||
@@ -439,8 +441,6 @@ describe("LocalCoreService", () => {
|
||||
localCoreService = new LocalCoreService();
|
||||
});
|
||||
|
||||
// @actions/core is mocked via jest.config.js moduleNameMapper
|
||||
|
||||
it("should have all required methods", () => {
|
||||
expect(typeof localCoreService.getInput).toBe("function");
|
||||
expect(typeof localCoreService.info).toBe("function");
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { defineConfig } from "vitest/config";
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
environment: "node",
|
||||
include: ["src/**/*.{spec,test}.ts"],
|
||||
coverage: {
|
||||
enabled: true,
|
||||
provider: "v8",
|
||||
include: ["src/**/*.ts"],
|
||||
exclude: ["src/**/*.{spec,test}.ts"],
|
||||
reporter: ["lcov"],
|
||||
reportsDirectory: "coverage",
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user