Skip to content

Commit dc8fb16

Browse files
Copilothotlong
andcommitted
Fix Jest ESM compatibility for @objectstack/core in plugin-validator
- Add mock for @objectstack/core to handle ESM import.meta usage - Update jest.config.js to use the mock via moduleNameMapper - Tests now pass successfully (71 tests passed) Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 55e35d2 commit dc8fb16

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

packages/foundation/plugin-validator/jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = {
1212
testMatch: ['**/test/**/*.test.ts'],
1313
moduleNameMapper: {
1414
'^@objectql/(.*)$': '<rootDir>/../$1/src',
15+
'^@objectstack/core$': '<rootDir>/test/__mocks__/@objectstack/core.ts',
1516
},
1617
transform: {
1718
'^.+\\.(t|j)sx?$': ['ts-jest', {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* ObjectQL
3+
* Copyright (c) 2026-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/**
10+
* Mock for @objectstack/core to enable Jest testing
11+
*
12+
* Since @objectstack/core@0.9.2 uses ES modules with import.meta,
13+
* which Jest doesn't support well, we provide this mock for testing.
14+
*/
15+
16+
export const createLogger = jest.fn(() => ({
17+
trace: jest.fn(),
18+
debug: jest.fn(),
19+
info: jest.fn(),
20+
warn: jest.fn(),
21+
error: jest.fn(),
22+
fatal: jest.fn(),
23+
}));
24+
25+
export const ObjectKernel = jest.fn();
26+
export const LiteKernel = jest.fn();
27+
export const createApiRegistryPlugin = jest.fn();

0 commit comments

Comments
 (0)