diff --git a/apps/server/package.json b/apps/server/package.json index 087a10b8d..0ec88c574 100644 --- a/apps/server/package.json +++ b/apps/server/package.json @@ -348,6 +348,12 @@ } ] } + }, + "test-build": { + "dependsOn": [ + "build" + ], + "command": "vitest --config {projectRoot}/vitest.build.config.mts" } } }, diff --git a/apps/server/spec/build-checks/artifacts.spec.ts b/apps/server/spec/build-checks/artifacts.spec.ts new file mode 100644 index 000000000..9b20eb681 --- /dev/null +++ b/apps/server/spec/build-checks/artifacts.spec.ts @@ -0,0 +1,46 @@ +import { globSync } from "fs"; +import { join } from "path"; +import { it, describe, expect } from "vitest"; + +describe("Check artifacts are present", () => { + const distPath = join(__dirname, "../../dist"); + + it("has the necessary node modules", async () => { + const paths = [ + "node_modules/better-sqlite3", + "node_modules/bindings", + "node_modules/file-uri-to-path" + ]; + + ensurePathsExist(paths); + }); + + it("includes the client", async () => { + const paths = [ + "public/assets", + "public/fonts", + "public/node_modules", + "public/src", + "public/stylesheets", + "public/translations" + ]; + + ensurePathsExist(paths); + }); + + it("includes necessary assets", async () => { + const paths = [ + "assets", + "share-theme" + ]; + + ensurePathsExist(paths); + }); + + function ensurePathsExist(paths: string[]) { + for (const path of paths) { + const result = globSync(join(distPath, path, "**")); + expect(result, path).not.toHaveLength(0); + } + } +}); diff --git a/apps/server/vite.config.mts b/apps/server/vite.config.mts index f67dede11..76829347a 100644 --- a/apps/server/vite.config.mts +++ b/apps/server/vite.config.mts @@ -11,6 +11,9 @@ export default defineConfig(() => ({ setupFiles: ["./spec/setup.ts"], environment: "node", include: ['{src,spec}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], + exclude: [ + "spec/build-checks/**", + ], reporters: [ "verbose" ], diff --git a/apps/server/vitest.build.config.mts b/apps/server/vitest.build.config.mts new file mode 100644 index 000000000..f9542fd55 --- /dev/null +++ b/apps/server/vitest.build.config.mts @@ -0,0 +1,18 @@ +/// +import { defineConfig } from 'vite'; + +export default defineConfig(() => ({ + root: __dirname, + cacheDir: '../../node_modules/.vite/apps/server', + plugins: [], + test: { + watch: false, + globals: true, + setupFiles: ["./spec/setup.ts"], + environment: "node", + include: ['spec/build-checks/**'], + reporters: [ + "verbose" + ] + }, +}));