From e75c09b1bde05b7a904a7bae3235156b1188a2c4 Mon Sep 17 00:00:00 2001 From: esgn <5435148+esgn@users.noreply.github.com> Date: Tue, 5 May 2026 11:55:35 +0200 Subject: [PATCH 1/2] feat: update CI workflows to use 'verify:fast' for testing and enhance README with typecheck commands --- .github/workflows/node.js.yml | 3 +-- .github/workflows/npm-publish.yml | 5 ++--- README.md | 4 ++++ package.json | 2 +- tsconfig.test.json | 3 ++- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 0b5d754..da07349 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -24,8 +24,7 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'npm' - run: npm ci - - run: npm run build --if-present - - run: npm test + - run: npm run verify:fast # basic functional testing # https://github.com/modelcontextprotocol/inspector?tab=readme-ov-file#cli-mode - name: List tools diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 91dce3d..fc261ab 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -13,8 +13,7 @@ jobs: with: node-version: 24.x - run: npm ci - - run: npm run build --if-present - - run: npm test + - run: npm run verify:fast publish-npm: needs: build @@ -26,7 +25,7 @@ jobs: node-version: 24.5.0 registry-url: https://registry.npmjs.org/ - run: npm ci - - run: npm run build --if-present + - run: npm run verify:fast - run: npm publish --access public env: NODE_AUTH_TOKEN: ${{secrets.npm_token}} diff --git a/README.md b/README.md index 9bd790c..dbc7977 100644 --- a/README.md +++ b/README.md @@ -201,6 +201,8 @@ export NO_PROXY=localhost,127.0.0.1 Les commandes principales sont : ```bash +npm run typecheck +npm run typecheck:test npm test npm run test:integration npm run test:e2e @@ -209,6 +211,8 @@ npm run verify npm run verify:full ``` +`npm run verify:fast` inclut le type-check de l'application et des fichiers de test avant le build et les tests unitaires. + Remarque : - Les outils `gpf_wfs_search_types` et `gpf_wfs_describe_type` s'appuient sur un catalogue de schémas embarqué fourni par `@ignfab/gpf-schema-store`. diff --git a/package.json b/package.json index 5fd72f8..b7fcb54 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "test:integration": "vitest run --config vitest.integration.config.mts", "test:e2e": "vitest run --config vitest.e2e.config.mts", "test:coverage": "vitest run --coverage", - "verify:fast": "npm run typecheck && npm run build && npm run test:unit", + "verify:fast": "npm run typecheck && npm run typecheck:test && npm run build && npm run test:unit", "verify": "npm run verify:fast && npm run test:integration", "verify:full": "npm run verify && npm run test:e2e", "fresh": "npm run reset:local && npm ci && npm run verify", diff --git a/tsconfig.test.json b/tsconfig.test.json index 086f1cf..b73c149 100644 --- a/tsconfig.test.json +++ b/tsconfig.test.json @@ -12,7 +12,8 @@ }, "include": [ "./src/**/*", - "./test/**/*" + "./test/**/*", + "./vitest*.mts" ], "exclude": [ "node_modules", From 2fdf2e3fdccac29fb811ac85a0cfeb6103ea0eb0 Mon Sep 17 00:00:00 2001 From: MBorne Date: Tue, 5 May 2026 14:30:13 +0200 Subject: [PATCH 2/2] chore(test): remove usage of globals for vitest, use explicit import --- test/gpf/adminexpress.test.ts | 2 +- test/gpf/altitude.test.ts | 1 + test/gpf/geocode.test.ts | 1 + test/gpf/parcellaire-express.test.ts | 2 +- test/gpf/urbanisme.test.ts | 2 +- test/gpf/wfs-schema-catalog.test.ts | 1 + test/helpers/distance.test.ts | 2 ++ test/helpers/http.test.ts | 2 +- test/helpers/toolError.test.ts | 2 +- test/helpers/wfs_engine/execution.test.ts | 2 +- test/helpers/wfs_engine/geometry.test.ts | 1 + test/helpers/wfs_engine/queryPreparation.test.ts | 1 + test/helpers/wfs_engine/request.test.ts | 1 + test/helpers/wfs_engine/response.test.ts | 2 ++ test/helpers/wfs_engine/spatialCql.test.ts | 2 ++ test/helpers/wfs_engine/spatialFilter.test.ts | 2 ++ test/integration/helpers/level1-assertions.ts | 4 ++-- test/tools/adminexpress.test.ts | 2 ++ test/tools/altitude.test.ts | 2 ++ test/tools/base-tool-error.test.ts | 2 ++ test/tools/cadastre.test.ts | 2 ++ test/tools/geocode.test.ts | 2 ++ test/tools/strict-input.test.ts | 2 ++ test/tools/urbanisme.test.ts | 2 ++ test/tools/wfs/describeType.test.ts | 2 ++ test/tools/wfs/getFeatureById.test.ts | 3 ++- test/tools/wfs/getFeatures.test.ts | 3 ++- test/tools/wfs/searchTypes.test.ts | 2 ++ vitest.config.mts | 2 +- vitest.e2e.config.mts | 2 +- vitest.integration.config.mts | 2 +- 31 files changed, 47 insertions(+), 13 deletions(-) diff --git a/test/gpf/adminexpress.test.ts b/test/gpf/adminexpress.test.ts index 7c5f0ea..816de61 100644 --- a/test/gpf/adminexpress.test.ts +++ b/test/gpf/adminexpress.test.ts @@ -1,4 +1,4 @@ -import { vi } from "vitest"; +import { vi, describe, expect, afterEach, beforeEach, it } from "vitest"; import { mairieLoray } from "../samples"; const mockGetFeatureType = vi.fn<(typename: string) => Promise>(); diff --git a/test/gpf/altitude.test.ts b/test/gpf/altitude.test.ts index 8375398..2112d8e 100644 --- a/test/gpf/altitude.test.ts +++ b/test/gpf/altitude.test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it } from "vitest"; import {getAltitudeByLocation} from "../../src/gpf/altitude.js"; import { paris } from "../samples"; diff --git a/test/gpf/geocode.test.ts b/test/gpf/geocode.test.ts index c6d00d0..de15a14 100644 --- a/test/gpf/geocode.test.ts +++ b/test/gpf/geocode.test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it } from "vitest"; import {geocode} from "../../src/gpf/geocode.js"; const rawGeocodeServiceResponse = { diff --git a/test/gpf/parcellaire-express.test.ts b/test/gpf/parcellaire-express.test.ts index f063997..9bc1ebf 100644 --- a/test/gpf/parcellaire-express.test.ts +++ b/test/gpf/parcellaire-express.test.ts @@ -1,4 +1,4 @@ -import { vi } from "vitest"; +import { vi, describe, expect, it, beforeEach, afterEach } from "vitest"; import { mairieLoray } from "../samples"; const mockGetFeatureType = vi.fn<(typename: string) => Promise>(); diff --git a/test/gpf/urbanisme.test.ts b/test/gpf/urbanisme.test.ts index f35c393..2bfc6d9 100644 --- a/test/gpf/urbanisme.test.ts +++ b/test/gpf/urbanisme.test.ts @@ -1,4 +1,4 @@ -import { vi } from "vitest"; +import { afterEach, beforeEach, describe, expect, vi, it } from "vitest"; import { chamonix, mairieLoray } from "../samples"; const mockGetFeatureType = vi.fn<(typename: string) => Promise>(); diff --git a/test/gpf/wfs-schema-catalog.test.ts b/test/gpf/wfs-schema-catalog.test.ts index 617b5a5..def7be1 100644 --- a/test/gpf/wfs-schema-catalog.test.ts +++ b/test/gpf/wfs-schema-catalog.test.ts @@ -1,3 +1,4 @@ +import { describe, expect, afterEach, beforeEach, it } from "vitest"; import { FeatureTypeNotFoundError, WfsClient, wfsClient, loadMiniSearchOptionsFromEnv } from "../../src/gpf/wfs-schema-catalog"; const GPF_WFS_MINISEARCH_OPTIONS_ENV = "GPF_WFS_MINISEARCH_OPTIONS"; diff --git a/test/helpers/distance.test.ts b/test/helpers/distance.test.ts index 9d9b8f2..09f9586 100644 --- a/test/helpers/distance.test.ts +++ b/test/helpers/distance.test.ts @@ -1,3 +1,5 @@ +import { describe, expect, it } from "vitest"; + import distance from "../../src/helpers/distance.js"; import type { Polygon } from "geojson"; import {paris, marseille, besancon, parisMarseille} from '../samples'; diff --git a/test/helpers/http.test.ts b/test/helpers/http.test.ts index b83b30a..7484dee 100644 --- a/test/helpers/http.test.ts +++ b/test/helpers/http.test.ts @@ -1,4 +1,4 @@ -import { afterEach, beforeEach, vi } from "vitest"; +import { afterEach, beforeEach, vi, describe, it, expect } from "vitest"; import fetch from "node-fetch"; vi.mock("node-fetch", async () => { diff --git a/test/helpers/toolError.test.ts b/test/helpers/toolError.test.ts index 5f5fe50..19895f8 100644 --- a/test/helpers/toolError.test.ts +++ b/test/helpers/toolError.test.ts @@ -1,5 +1,5 @@ +import { vi, describe, it, expect } from "vitest"; import { z } from "zod"; -import { vi } from "vitest"; import { ServiceResponseError } from "../../src/helpers/http.js"; import { normalizeToolError } from "../../src/helpers/errors/toolError.js"; diff --git a/test/helpers/wfs_engine/execution.test.ts b/test/helpers/wfs_engine/execution.test.ts index 40e3d9f..3f3da0d 100644 --- a/test/helpers/wfs_engine/execution.test.ts +++ b/test/helpers/wfs_engine/execution.test.ts @@ -1,4 +1,4 @@ -import { vi } from "vitest"; +import { vi, describe, expect, afterEach, it } from "vitest"; const mockFetchJSONPost = vi.fn<( url: string, diff --git a/test/helpers/wfs_engine/geometry.test.ts b/test/helpers/wfs_engine/geometry.test.ts index 7f194e6..07b5890 100644 --- a/test/helpers/wfs_engine/geometry.test.ts +++ b/test/helpers/wfs_engine/geometry.test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it } from "vitest"; import { geometryToEwkt } from "../../../src/helpers/wfs_engine/geometry"; describe("geometryToEwkt", () => { diff --git a/test/helpers/wfs_engine/queryPreparation.test.ts b/test/helpers/wfs_engine/queryPreparation.test.ts index e761e81..2d93d69 100644 --- a/test/helpers/wfs_engine/queryPreparation.test.ts +++ b/test/helpers/wfs_engine/queryPreparation.test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it } from "vitest"; import type { Collection } from "@ignfab/gpf-schema-store"; import { compileQueryParts, geometryToEwkt } from "../../../src/helpers/wfs_engine/queryPreparation"; diff --git a/test/helpers/wfs_engine/request.test.ts b/test/helpers/wfs_engine/request.test.ts index f6b8117..b6f4927 100644 --- a/test/helpers/wfs_engine/request.test.ts +++ b/test/helpers/wfs_engine/request.test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it } from "vitest"; import { buildMultiTypenameRequest } from "../../../src/helpers/wfs_engine/request"; describe("wfs_engine/request", () => { diff --git a/test/helpers/wfs_engine/response.test.ts b/test/helpers/wfs_engine/response.test.ts index 0abc47c..fd78ce2 100644 --- a/test/helpers/wfs_engine/response.test.ts +++ b/test/helpers/wfs_engine/response.test.ts @@ -1,3 +1,5 @@ +import { describe, expect, it } from "vitest"; + import { mapToFlatItems, mapToFlatItemsWithGeometry, diff --git a/test/helpers/wfs_engine/spatialCql.test.ts b/test/helpers/wfs_engine/spatialCql.test.ts index 5360714..78b177d 100644 --- a/test/helpers/wfs_engine/spatialCql.test.ts +++ b/test/helpers/wfs_engine/spatialCql.test.ts @@ -1,3 +1,5 @@ +import { describe, expect, it } from "vitest"; + import { compileBboxSpatialFilter, compileIntersectsPointSpatialFilter, diff --git a/test/helpers/wfs_engine/spatialFilter.test.ts b/test/helpers/wfs_engine/spatialFilter.test.ts index dbeb3e2..50acc3f 100644 --- a/test/helpers/wfs_engine/spatialFilter.test.ts +++ b/test/helpers/wfs_engine/spatialFilter.test.ts @@ -1,3 +1,5 @@ +import { describe, expect, it } from "vitest"; + import { getSpatialFilter } from "../../../src/helpers/wfs_engine/spatialFilter"; import type { GpfWfsGetFeaturesInput } from "../../../src/helpers/wfs_engine/schema"; diff --git a/test/integration/helpers/level1-assertions.ts b/test/integration/helpers/level1-assertions.ts index f849f4c..ed4242f 100644 --- a/test/integration/helpers/level1-assertions.ts +++ b/test/integration/helpers/level1-assertions.ts @@ -21,7 +21,7 @@ export function expectNonEmptyResults( minimum = 1, ): asserts value is { results: T[] } { expect(value.results).toBeDefined(); - expect(value.results.length).toBeGreaterThanOrEqual(minimum); + expect(value.results!.length).toBeGreaterThanOrEqual(minimum); } /** @@ -37,7 +37,7 @@ export function expectFeatureCollectionWithFeatures( ): asserts value is { type: "FeatureCollection"; features: TFeature[] } { expect(value.type).toBe("FeatureCollection"); expect(value.features).toBeDefined(); - expect(value.features.length).toBeGreaterThanOrEqual(minimum); + expect(value.features!.length).toBeGreaterThanOrEqual(minimum); } /** diff --git a/test/tools/adminexpress.test.ts b/test/tools/adminexpress.test.ts index 4c9e8f3..26d7dc2 100644 --- a/test/tools/adminexpress.test.ts +++ b/test/tools/adminexpress.test.ts @@ -1,3 +1,5 @@ +import { describe, it, expect } from "vitest"; + import AdminexpressTool from "../../src/tools/AdminexpressTool"; import { mairieLoray } from "../samples"; diff --git a/test/tools/altitude.test.ts b/test/tools/altitude.test.ts index f6c03e5..c79335f 100644 --- a/test/tools/altitude.test.ts +++ b/test/tools/altitude.test.ts @@ -1,3 +1,5 @@ +import { describe, it, expect } from "vitest"; + import AltitudeTool from "../../src/tools/AltitudeTool"; import { paris } from "../samples"; diff --git a/test/tools/base-tool-error.test.ts b/test/tools/base-tool-error.test.ts index 99f55a5..df6e983 100644 --- a/test/tools/base-tool-error.test.ts +++ b/test/tools/base-tool-error.test.ts @@ -1,3 +1,5 @@ +import { describe, it, expect } from "vitest"; + import { z } from "zod"; import BaseTool from "../../src/tools/BaseTool.js"; diff --git a/test/tools/cadastre.test.ts b/test/tools/cadastre.test.ts index b5bce97..d421b73 100644 --- a/test/tools/cadastre.test.ts +++ b/test/tools/cadastre.test.ts @@ -1,3 +1,5 @@ +import { describe, it, expect } from "vitest"; + import CadastreTool from "../../src/tools/CadastreTool"; import { mairieLoray } from "../samples"; diff --git a/test/tools/geocode.test.ts b/test/tools/geocode.test.ts index 8ac2a6e..b54aeed 100644 --- a/test/tools/geocode.test.ts +++ b/test/tools/geocode.test.ts @@ -1,3 +1,5 @@ +import { describe, it, expect } from "vitest"; + import GeocodeTool from "../../src/tools/GeocodeTool"; describe("Test GeocodeTool",() => { diff --git a/test/tools/strict-input.test.ts b/test/tools/strict-input.test.ts index 0a0fc1a..c541a3a 100644 --- a/test/tools/strict-input.test.ts +++ b/test/tools/strict-input.test.ts @@ -1,3 +1,5 @@ +import { describe, it, expect } from "vitest"; + import AdminexpressTool from "../../src/tools/AdminexpressTool"; import AltitudeTool from "../../src/tools/AltitudeTool"; import AssietteSupTool from "../../src/tools/AssietteSupTool"; diff --git a/test/tools/urbanisme.test.ts b/test/tools/urbanisme.test.ts index b3a3d0e..66bfdca 100644 --- a/test/tools/urbanisme.test.ts +++ b/test/tools/urbanisme.test.ts @@ -1,3 +1,5 @@ +import { describe, it, expect } from "vitest"; + import AssietteSupTool from "../../src/tools/AssietteSupTool"; import UrbanismeTool from "../../src/tools/UrbanismeTool"; import { chamonix, mairieLoray } from "../samples"; diff --git a/test/tools/wfs/describeType.test.ts b/test/tools/wfs/describeType.test.ts index a482457..c1b65a1 100644 --- a/test/tools/wfs/describeType.test.ts +++ b/test/tools/wfs/describeType.test.ts @@ -1,3 +1,5 @@ +import { describe, it, expect } from "vitest"; + import type { Collection } from "@ignfab/gpf-schema-store"; import GpfWfsDescribeTypeTool from "../../../src/tools/GpfWfsDescribeTypeTool"; diff --git a/test/tools/wfs/getFeatureById.test.ts b/test/tools/wfs/getFeatureById.test.ts index 444220f..f449283 100644 --- a/test/tools/wfs/getFeatureById.test.ts +++ b/test/tools/wfs/getFeatureById.test.ts @@ -1,5 +1,6 @@ +import { vi, describe, it, expect, afterEach } from "vitest"; + import type { Collection } from "@ignfab/gpf-schema-store"; -import { vi } from "vitest"; import { ServiceResponseError } from "../../../src/helpers/http.js"; const mockGetFeatureType = vi.fn<(typename: string) => Promise>(); diff --git a/test/tools/wfs/getFeatures.test.ts b/test/tools/wfs/getFeatures.test.ts index dda2f39..17c86ee 100644 --- a/test/tools/wfs/getFeatures.test.ts +++ b/test/tools/wfs/getFeatures.test.ts @@ -1,5 +1,6 @@ +import { vi, describe, it, expect, afterEach } from "vitest"; + import type { Collection } from "@ignfab/gpf-schema-store"; -import { vi } from "vitest"; import { ServiceResponseError } from "../../../src/helpers/http.js"; const mockGetFeatureType = vi.fn<(typename: string) => Promise>(); diff --git a/test/tools/wfs/searchTypes.test.ts b/test/tools/wfs/searchTypes.test.ts index 28c727f..3188cc0 100644 --- a/test/tools/wfs/searchTypes.test.ts +++ b/test/tools/wfs/searchTypes.test.ts @@ -1,3 +1,5 @@ +import { describe, it, expect } from "vitest"; + import GpfWfsSearchTypesTool from "../../../src/tools/GpfWfsSearchTypesTool"; describe("Test GpfWfsSearchTypesTool",() => { diff --git a/vitest.config.mts b/vitest.config.mts index 3d35c08..c016466 100644 --- a/vitest.config.mts +++ b/vitest.config.mts @@ -12,7 +12,7 @@ export default defineConfig({ ], }, test: { - globals: true, + globals: false, environment: "node", include: ["test/**/*.test.ts"], exclude: ["test/integration/**/*"], diff --git a/vitest.e2e.config.mts b/vitest.e2e.config.mts index b9291e3..51b53e0 100644 --- a/vitest.e2e.config.mts +++ b/vitest.e2e.config.mts @@ -12,7 +12,7 @@ export default defineConfig({ ], }, test: { - globals: true, + globals: false, environment: "node", include: ["test/integration/level2-agent/**/*.test.ts"], testTimeout: 120 * MILLISECONDS, diff --git a/vitest.integration.config.mts b/vitest.integration.config.mts index 7460ebf..22a50e1 100644 --- a/vitest.integration.config.mts +++ b/vitest.integration.config.mts @@ -12,7 +12,7 @@ export default defineConfig({ ], }, test: { - globals: true, + globals: false, environment: "node", include: ["test/integration/level1-protocol/**/*.test.ts"], testTimeout: 60 * MILLISECONDS,