🔧 fix: repair test, build and CI infrastructure
The vitest suite silently ran zero tests: vitest 4 transpiles with oxc, which does not pick up `experimentalDecorators` from a tsconfig that excludes the files being transformed, so every decorator-using suite failed to parse and was reported as "0 test". A vitest.config.ts enabling legacy decorators brings all 40 existing tests back to life. - Add vitest.config.ts (oxc legacy decorators + v8 coverage config) - Type-check test files: move the test/demo exclusions from the base tsconfig onto the two build configs, and fix the strict-mode errors this surfaced - Stop shipping src/example.ts in dist (it invokes runExample() at import time, a side effect in a package declaring "sideEffects": false) - CI: run lint, tests with coverage, build and entry-point smoke checks; drop EOL Node 18, add Node 24; commit package-lock.json so `npm ci` works - Add `verify`, `test:watch` and `build:docs` scripts, and an engines field; `build:docs` regenerates the previously hand-maintained docs/cereale.js Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SAcqrz3FcadkYr3xG32CjK
This commit is contained in:
@@ -238,7 +238,7 @@ describe('Additional Decorators', () => {
|
||||
t.val = 'wrong';
|
||||
const errors = await JsonMapper.validate(t);
|
||||
expect(errors).toHaveLength(1);
|
||||
expect(errors[0].constraints['CustomValidator']).toBe('val must be correct');
|
||||
expect(errors[0]!.constraints['CustomValidator']).toBe('val must be correct');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -304,7 +304,7 @@ describe('Additional Decorators', () => {
|
||||
t.val = 5;
|
||||
const errors = await JsonMapper.validate(t);
|
||||
expect(errors).toHaveLength(1);
|
||||
expect(errors[0].constraints['custom']).toBe('must be ten');
|
||||
expect(errors[0]!.constraints['custom']).toBe('must be ten');
|
||||
});
|
||||
|
||||
it('should handle options as second argument', async () => {
|
||||
@@ -318,7 +318,7 @@ describe('Additional Decorators', () => {
|
||||
t.val = 2;
|
||||
const errors = await JsonMapper.validate(t);
|
||||
expect(errors).toHaveLength(1);
|
||||
expect(errors[0].constraints['custom']).toBe('must be one');
|
||||
expect(errors[0]!.constraints['custom']).toBe('must be one');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -339,10 +339,10 @@ describe('Additional Decorators', () => {
|
||||
name: string;
|
||||
}
|
||||
const json = '[{"name": "a"}, {"name": "b"}]';
|
||||
const items = await JsonMapper.fromJson(Item, json);
|
||||
const items = (await JsonMapper.fromJson(Item, json)) as unknown as Item[];
|
||||
expect(Array.isArray(items)).toBe(true);
|
||||
expect(items[0]).toBeInstanceOf(Item);
|
||||
expect(items[0].name).toBe('a');
|
||||
expect(items[0]!.name).toBe('a');
|
||||
});
|
||||
|
||||
it('should handle single polymorphic object', async () => {
|
||||
@@ -350,7 +350,7 @@ describe('Additional Decorators', () => {
|
||||
@IsString() type: string;
|
||||
}
|
||||
class Dog extends Animal {
|
||||
type = 'dog';
|
||||
override type = 'dog';
|
||||
@IsString() breed: string;
|
||||
}
|
||||
class Test {
|
||||
@@ -376,7 +376,7 @@ describe('Additional Decorators', () => {
|
||||
t.tags = ['a', 1 as any];
|
||||
const errors = await JsonMapper.validate(t);
|
||||
expect(errors).toHaveLength(1);
|
||||
expect(errors[0].constraints['isString']).toContain('each element');
|
||||
expect(errors[0]!.constraints['isString']).toContain('each element');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user