mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 01:44:13 +00:00
test(server): keep the new gate tests inside the tests' type check
coverage-thresholds.test.ts imported vitest.config.ts, which pulled the config into tsconfig.tests.json's program; that program compiles as CommonJS and rejects the config's import.meta, so typecheck:tests failed. The test now loads the config at runtime. The other new gate tests get prettier's formatting.
This commit is contained in:
@@ -8,11 +8,11 @@
|
||||
* violation, that what the rules deliberately ignore stays ignored, and that a
|
||||
* broken setup stops the run instead of passing it.
|
||||
*/
|
||||
import { afterEach, describe, expect, it } from 'vitest';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { afterEach, describe, expect, it } from 'vitest';
|
||||
|
||||
const SCRIPT = path.join(__dirname, '../../../scripts/import-boundaries.mjs');
|
||||
|
||||
@@ -140,7 +140,10 @@ describe('import-boundaries.mjs', () => {
|
||||
expect(run(ok).status).toBe(0);
|
||||
|
||||
// Type-only still counts: it couples A to B's private shapes all the same.
|
||||
const bad = serverRoot({ ...files, 'nest/a/sub/a.thing.ts': "import type { h } from '../../b/b.helpers';\nexport type X = typeof h;\n" });
|
||||
const bad = serverRoot({
|
||||
...files,
|
||||
'nest/a/sub/a.thing.ts': "import type { h } from '../../b/b.helpers';\nexport type X = typeof h;\n",
|
||||
});
|
||||
const { status, out } = run(bad);
|
||||
expect(status).toBe(1);
|
||||
expect(out).toContain('FAIL domainInternals: a -> b/b.helpers.ts');
|
||||
@@ -149,7 +152,8 @@ describe('import-boundaries.mjs', () => {
|
||||
it('BOUND-006: fails when a shared-kernel file imports a domain', () => {
|
||||
const dir = serverRoot({
|
||||
'nest/auth/jwt-auth.guard.ts': 'export class JwtAuthGuard {}\n',
|
||||
'nest/common/validate.ts': "import { JwtAuthGuard } from '../auth/jwt-auth.guard';\nexport const g = JwtAuthGuard;\n",
|
||||
'nest/common/validate.ts':
|
||||
"import { JwtAuthGuard } from '../auth/jwt-auth.guard';\nexport const g = JwtAuthGuard;\n",
|
||||
});
|
||||
const { status, out } = run(dir);
|
||||
expect(status).toBe(1);
|
||||
@@ -181,7 +185,9 @@ describe('import-boundaries.mjs', () => {
|
||||
expect(check.out).toContain('1 baseline entry no longer occurs');
|
||||
|
||||
expect(run(dir, '--update').status).toBe(1);
|
||||
const written: unknown = JSON.parse(readFileSync(path.join(dir, 'scripts/import-boundaries-baseline.json'), 'utf8'));
|
||||
const written: unknown = JSON.parse(
|
||||
readFileSync(path.join(dir, 'scripts/import-boundaries-baseline.json'), 'utf8'),
|
||||
);
|
||||
expect(written).toEqual({ ...EMPTY, domainInternals: ['a -> b/b.helpers.ts'] });
|
||||
});
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
* fails on a violation and that it refuses to run on a broken setup instead
|
||||
* of passing silently.
|
||||
*/
|
||||
import { afterEach, describe, expect, it } from 'vitest';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { afterEach, describe, expect, it } from 'vitest';
|
||||
|
||||
const SCRIPT = path.join(__dirname, '../../../scripts/size-lint.mjs');
|
||||
|
||||
@@ -130,7 +130,12 @@ describe('size-lint.mjs', () => {
|
||||
|
||||
it('SIZE-009: --update only lowers, drops files back under the limit, and never adds one', () => {
|
||||
const dir = serverRoot(
|
||||
{ 'src/shrunk.ts': lines(1100), 'src/fixed.ts': lines(50), 'src/grown.ts': lines(1500), 'src/new.ts': lines(1300) },
|
||||
{
|
||||
'src/shrunk.ts': lines(1100),
|
||||
'src/fixed.ts': lines(50),
|
||||
'src/grown.ts': lines(1500),
|
||||
'src/new.ts': lines(1300),
|
||||
},
|
||||
{ 'src/shrunk.ts': 1200, 'src/fixed.ts': 1300, 'src/grown.ts': 1400, 'src/gone.ts': 1100 },
|
||||
);
|
||||
const { status } = run(dir, '--update');
|
||||
|
||||
Reference in New Issue
Block a user