mirror of
https://github.com/n8n-io/n8n.git
synced 2026-08-29 01:39:24 +08:00
chore: Clean up dangling Jest artifacts (#34446)
This commit is contained in:
@@ -6,8 +6,7 @@ export default mergeConfig(createVitestConfig({}), {
|
||||
resolve: {
|
||||
alias: [
|
||||
// @inquirer/prompts and its sub-packages are ESM-only. Tests redirect
|
||||
// any @inquirer/* import to this mock (mirrors the former Jest
|
||||
// moduleNameMapper).
|
||||
// any @inquirer/* import to this mock.
|
||||
{
|
||||
find: /^@inquirer\/.*$/,
|
||||
replacement: path.resolve(__dirname, './src/__mocks__/@inquirer/prompts.ts'),
|
||||
|
||||
@@ -145,10 +145,8 @@ interface EovApiDoc {
|
||||
*
|
||||
* Why it's needed in tests: eov's default resolver `require()`s each handler module, but under
|
||||
* Vitest only the `.ts` handler sources exist on disk (no `.js`) and they're served by Vite, not
|
||||
* Node's `require` — so `require()` throws and every route 500s. (Under Jest this worked via
|
||||
* ts-jest's require hook, which Vitest has no equivalent of.) `import()` is intercepted by Vite and
|
||||
* resolves the `.ts`. Mirrors eov's `defaultResolver` lookup (`mod[id]` / `mod.default[id]` / `mod.default`).
|
||||
*/
|
||||
* Node's `require` — so `require()` throws and every route 500s.
|
||||
* */
|
||||
async function importOperationHandlerResolver(
|
||||
handlersPath: string,
|
||||
// Typed as `unknown` (then narrowed) so the signature stays assignable to eov's
|
||||
|
||||
@@ -418,8 +418,6 @@ describe('WorkflowExecutionService', () => {
|
||||
dirtyNodeNames: [],
|
||||
} as WorkflowRequest.ManualRunPayload;
|
||||
|
||||
// Not jest.spyOn/vi.spyOn: the mock proxy exposes mock methods
|
||||
// directly, keeping this test agnostic of the test runner
|
||||
nodeTypes.getByNameAndVersion.mockReturnValueOnce(
|
||||
mock<INodeType>({ description: { group: [] } }),
|
||||
);
|
||||
|
||||
@@ -6,8 +6,6 @@ import {
|
||||
validateJSON,
|
||||
} from '../GenericFunctions';
|
||||
|
||||
const jest = vi;
|
||||
|
||||
type RequestOptions = {
|
||||
method?: string;
|
||||
uri?: string;
|
||||
@@ -19,7 +17,7 @@ type RequestOptions = {
|
||||
|
||||
describe('RocketChat > GenericFunctions', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('validateJSON', () => {
|
||||
@@ -46,10 +44,10 @@ describe('RocketChat > GenericFunctions', () => {
|
||||
|
||||
describe('rocketchatApiRequest', () => {
|
||||
function createContext() {
|
||||
const requestWithAuthentication = jest.fn();
|
||||
const requestWithAuthentication = vi.fn();
|
||||
|
||||
const context = {
|
||||
getCredentials: jest.fn().mockResolvedValue({
|
||||
getCredentials: vi.fn().mockResolvedValue({
|
||||
domain: 'https://chat.example.com',
|
||||
}),
|
||||
helpers: {
|
||||
@@ -127,10 +125,10 @@ describe('RocketChat > GenericFunctions', () => {
|
||||
|
||||
describe('rocketchatApiRequestAllItems', () => {
|
||||
function createContext() {
|
||||
const requestWithAuthentication = jest.fn();
|
||||
const requestWithAuthentication = vi.fn();
|
||||
|
||||
const context = {
|
||||
getCredentials: jest.fn().mockResolvedValue({
|
||||
getCredentials: vi.fn().mockResolvedValue({
|
||||
domain: 'https://chat.example.com',
|
||||
}),
|
||||
helpers: {
|
||||
|
||||
Reference in New Issue
Block a user