From 38517befe6790378758f8c58af64a238951bbc48 Mon Sep 17 00:00:00 2001 From: Anthuan Vasquez Date: Sun, 26 Apr 2026 16:27:53 -0400 Subject: [PATCH 1/6] fix(ci): use valid vitest command in workflow --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d291c78..ed2eac7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,4 +49,4 @@ jobs: run: pnpm install - name: Run tests - run: pnpm test run + run: pnpm test From 554e5dd6649ac1ad652bb8ea7e3e973d1c1cc725 Mon Sep 17 00:00:00 2001 From: Anthuan Vasquez Date: Wed, 27 May 2026 20:35:39 -0400 Subject: [PATCH 2/6] fix(test): mock better-sqlite3 to resolve CI native binding error better-sqlite3 is a native addon that fails to load its compiled bindings in the GitHub Actions Linux runner. The @nuxt/content module attempts to initialize SQLite via better-sqlite3 during Vitest environment setup, causing a startup error before any test runs. Add a stub mock (tests/mocks/better-sqlite3.ts) that satisfies the better-sqlite3 API surface and register it as a Vitest alias so the native binary is never loaded in the test environment. Closes #81 --- tests/mocks/better-sqlite3.ts | 53 +++++++++++++++++++++++++++++++++++ vitest.config.ts | 6 ++++ 2 files changed, 59 insertions(+) create mode 100644 tests/mocks/better-sqlite3.ts diff --git a/tests/mocks/better-sqlite3.ts b/tests/mocks/better-sqlite3.ts new file mode 100644 index 0000000..705fc3a --- /dev/null +++ b/tests/mocks/better-sqlite3.ts @@ -0,0 +1,53 @@ +class Statement { + run(..._args: unknown[]) { + return { changes: 0, lastInsertRowid: 0 }; + } + get(..._args: unknown[]) { + return undefined; + } + all(..._args: unknown[]) { + return []; + } + iterate(..._args: unknown[]) { + return [][Symbol.iterator](); + } +} + +class Database { + inTransaction = false; + readonly = false; + memory = false; + name = ':mock:'; + open = true; + + constructor(_path: string, _options?: unknown) {} + + exec(_sql: string) { + return this; + } + + prepare(_sql: string) { + return new Statement(); + } + + close() {} + + transaction(fn: (...args: unknown[]) => unknown) { + return (...args: unknown[]) => fn(...args); + } + + pragma(_pragma: string, _options?: unknown) { + return []; + } + + backup(_destination: string) { + return Promise.resolve(); + } + + serialize(_options?: unknown) { + return Buffer.alloc(0); + } +} + +export default Database; +export { Database }; diff --git a/vitest.config.ts b/vitest.config.ts index 664a770..466bbdf 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -18,6 +18,12 @@ export default defineVitestConfig({ new URL('./tests/mocks/mapbox-gl.ts', import.meta.url) ), }, + { + find: 'better-sqlite3', + replacement: fileURLToPath( + new URL('./tests/mocks/better-sqlite3.ts', import.meta.url) + ), + }, ], }, }); From 6796bdf6c198f69bd320073a741109471c28db52 Mon Sep 17 00:00:00 2001 From: Anthuan Vasquez Date: Wed, 27 May 2026 20:41:30 -0400 Subject: [PATCH 3/6] fix(ci): rebuild better-sqlite3 from source before running tests The prebuilt binary for better-sqlite3@12.6.2 targets Node 20.20.2 but the GitHub Actions runner may use a different Node 20 patch version, causing the native binding lookup to fail at Vitest startup. Adding an explicit pnpm rebuild step compiles the native addon from source against the exact Node.js version on the runner, eliminating the version mismatch. --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed2eac7..115322c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,5 +48,8 @@ jobs: - name: Install dependencies run: pnpm install + - name: Rebuild native dependencies + run: pnpm rebuild better-sqlite3 + - name: Run tests run: pnpm test From b9e72c5e62187296e28be4109a800b32bf52ef1c Mon Sep 17 00:00:00 2001 From: Anthuan Vasquez Date: Wed, 27 May 2026 20:59:41 -0400 Subject: [PATCH 4/6] fix(test): exclude @nuxt/content from Vitest Nuxt environment @nuxt/content initializes better-sqlite3 (a native addon) during Nuxt module setup, which fails in CI Linux runners because the prebuilt binary does not match the runner's Node.js version. No test in the suite depends on content functionality. Excluding the module via environmentOptions.nuxt.overrides prevents the native addon from loading entirely, eliminating the startup crash. Also reverts the pnpm rebuild step which ran silently with no effect. --- .github/workflows/ci.yml | 3 --- vitest.config.ts | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 115322c..ed2eac7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,8 +48,5 @@ jobs: - name: Install dependencies run: pnpm install - - name: Rebuild native dependencies - run: pnpm rebuild better-sqlite3 - - name: Run tests run: pnpm test diff --git a/vitest.config.ts b/vitest.config.ts index 466bbdf..37db69f 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -4,6 +4,23 @@ import { fileURLToPath } from 'node:url'; export default defineVitestConfig({ test: { environment: 'nuxt', + environmentOptions: { + nuxt: { + overrides: { + // Exclude @nuxt/content from the test environment — it initializes + // better-sqlite3 (a native addon) which fails in CI Linux runners. + // No tests depend on content functionality. + modules: [ + '@nuxt/ui', + '@nuxt/image', + '@nuxt/eslint', + '@nuxt/test-utils/module', + 'nuxt-mapbox', + 'motion-v/nuxt', + ], + }, + }, + }, setupFiles: ['./tests/setup.ts'], alias: [ { From c3e0eed9733af29accbb015774bafca5b36c79b5 Mon Sep 17 00:00:00 2001 From: Anthuan Vasquez Date: Wed, 27 May 2026 21:04:07 -0400 Subject: [PATCH 5/6] fix(test): skip @nuxt/content when running under Vitest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit better-sqlite3 (native addon used by @nuxt/content) fails to load its prebuilt binary in CI Linux runners due to a Node.js version mismatch. No test in the suite depends on content functionality. Use process.env.VITEST — set automatically by Vitest — to conditionally exclude @nuxt/content from the modules list, preventing the native addon from being initialized during test runs. --- nuxt.config.ts | 4 +++- vitest.config.ts | 17 ----------------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/nuxt.config.ts b/nuxt.config.ts index 6df8da6..b5c77ea 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -8,13 +8,15 @@ export default defineNuxtConfig({ /** * Nuxt Modules + * @nuxt/content is excluded in test env — it initializes better-sqlite3 + * (a native addon) which fails in CI Linux runners. */ modules: [ '@nuxt/ui', '@nuxt/image', '@nuxt/eslint', '@nuxt/test-utils/module', - '@nuxt/content', + ...(!process.env.VITEST ? ['@nuxt/content'] : []), 'nuxt-mapbox', 'motion-v/nuxt', ], diff --git a/vitest.config.ts b/vitest.config.ts index 37db69f..466bbdf 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -4,23 +4,6 @@ import { fileURLToPath } from 'node:url'; export default defineVitestConfig({ test: { environment: 'nuxt', - environmentOptions: { - nuxt: { - overrides: { - // Exclude @nuxt/content from the test environment — it initializes - // better-sqlite3 (a native addon) which fails in CI Linux runners. - // No tests depend on content functionality. - modules: [ - '@nuxt/ui', - '@nuxt/image', - '@nuxt/eslint', - '@nuxt/test-utils/module', - 'nuxt-mapbox', - 'motion-v/nuxt', - ], - }, - }, - }, setupFiles: ['./tests/setup.ts'], alias: [ { From bf0f493b36eabec45f2a36bedcdec53b5259dcc8 Mon Sep 17 00:00:00 2001 From: Anthuan Vasquez Date: Wed, 27 May 2026 21:07:40 -0400 Subject: [PATCH 6/6] chore(test): remove unused better-sqlite3 mock --- tests/mocks/better-sqlite3.ts | 53 ----------------------------------- vitest.config.ts | 6 ---- 2 files changed, 59 deletions(-) delete mode 100644 tests/mocks/better-sqlite3.ts diff --git a/tests/mocks/better-sqlite3.ts b/tests/mocks/better-sqlite3.ts deleted file mode 100644 index 705fc3a..0000000 --- a/tests/mocks/better-sqlite3.ts +++ /dev/null @@ -1,53 +0,0 @@ -class Statement { - run(..._args: unknown[]) { - return { changes: 0, lastInsertRowid: 0 }; - } - get(..._args: unknown[]) { - return undefined; - } - all(..._args: unknown[]) { - return []; - } - iterate(..._args: unknown[]) { - return [][Symbol.iterator](); - } -} - -class Database { - inTransaction = false; - readonly = false; - memory = false; - name = ':mock:'; - open = true; - - constructor(_path: string, _options?: unknown) {} - - exec(_sql: string) { - return this; - } - - prepare(_sql: string) { - return new Statement(); - } - - close() {} - - transaction(fn: (...args: unknown[]) => unknown) { - return (...args: unknown[]) => fn(...args); - } - - pragma(_pragma: string, _options?: unknown) { - return []; - } - - backup(_destination: string) { - return Promise.resolve(); - } - - serialize(_options?: unknown) { - return Buffer.alloc(0); - } -} - -export default Database; -export { Database }; diff --git a/vitest.config.ts b/vitest.config.ts index 466bbdf..664a770 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -18,12 +18,6 @@ export default defineVitestConfig({ new URL('./tests/mocks/mapbox-gl.ts', import.meta.url) ), }, - { - find: 'better-sqlite3', - replacement: fileURLToPath( - new URL('./tests/mocks/better-sqlite3.ts', import.meta.url) - ), - }, ], }, });