diff --git a/.changeset/good-paws-build.md b/.changeset/good-paws-build.md new file mode 100644 index 0000000..a845151 --- /dev/null +++ b/.changeset/good-paws-build.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3ee9b5..0fde13d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,4 +46,7 @@ jobs: run: pnpm test:coverage - name: Build - run: pnpm build \ No newline at end of file + run: pnpm build + + - name: Test build exports + run: pnpm test:build \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 42f71fb..6dc1eb4 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -65,6 +65,9 @@ jobs: - name: Build run: pnpm build + - name: Test build exports + run: pnpm test:build + - name: Apply changesets id: version run: | diff --git a/package.json b/package.json index e0363d6..acf1db5 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,7 @@ "prepare": "simple-git-hooks", "release": "pnpm publish --access public --provenance --no-git-checks", "test": "rstest run", + "test:build": "rstest run --config rstest.build.config.ts", "test:coverage": "rstest run --coverage", "test:related": "rstest run --passWithNoTests", "test:watch": "rstest watch" diff --git a/rstest.build.config.ts b/rstest.build.config.ts new file mode 100644 index 0000000..8477a26 --- /dev/null +++ b/rstest.build.config.ts @@ -0,0 +1,9 @@ +import { withRslibConfig } from '@rstest/adapter-rslib'; +import { defineConfig } from '@rstest/core'; + +export default defineConfig({ + extends: withRslibConfig(), + globals: true, + testEnvironment: 'node', + include: ['test/**/*.test.ts'], +}); diff --git a/rstest.config.ts b/rstest.config.ts index a182e5f..ecfd367 100644 --- a/rstest.config.ts +++ b/rstest.config.ts @@ -5,6 +5,7 @@ export default defineConfig({ extends: withRslibConfig(), globals: true, testEnvironment: 'happy-dom', + include: ['src/**/*.test.ts'], coverage: { provider: 'istanbul', thresholds: { diff --git a/test/build.test.ts b/test/build.test.ts new file mode 100644 index 0000000..5214670 --- /dev/null +++ b/test/build.test.ts @@ -0,0 +1,43 @@ +/** + * Smoke tests that run against the compiled dist/ output. + * Verifies every public module is importable and all expected exports are present. + * Run after `pnpm build` via `pnpm test:build`. + */ + +describe('@rstackio/services/safe', () => { + it('exports safe()', async () => { + const mod = await import('../dist/safe/index.js'); + expect(mod.safe).toBeTypeOf('function'); + }); +}); + +describe('@rstackio/services/data-provider', () => { + it('exports createSafeProvider() and createProvider()', async () => { + const mod = await import('../dist/data-provider/index.js'); + expect(mod.createSafeProvider).toBeTypeOf('function'); + expect(mod.createProvider).toBeTypeOf('function'); + }); +}); + +describe('@rstackio/services/mock', () => { + it('exports mock utilities', async () => { + const mod = await import('../dist/mock/index.js'); + expect(mod.isMockEnabled).toBeTypeOf('function'); + expect(mod.enableMock).toBeTypeOf('function'); + expect(mod.disableMock).toBeTypeOf('function'); + expect(mod.delay).toBeTypeOf('function'); + }); +}); + +describe('@rstackio/services/logger', () => { + it('exports Logger class', async () => { + const mod = await import('../dist/logger/index.js'); + expect(mod.Logger).toBeTypeOf('function'); + }); +}); + +describe('@rstackio/services/errors', () => { + it('is importable (type-only module)', async () => { + await expect(import('../dist/errors/index.js')).resolves.toBeDefined(); + }); +}); diff --git a/test/tsconfig.json b/test/tsconfig.json new file mode 100644 index 0000000..379a994 --- /dev/null +++ b/test/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../tsconfig.json", + "include": ["."] +}