fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #2778 from hey-api/test/examples-unit-tests

test: test examples only if we build them

authored by

Lubos and committed by
GitHub
5cac74a4 de996450

+15 -85
+2 -2
.github/copilot-instructions.md
··· 8 8 9 9 ### Prerequisites and Setup 10 10 11 - - Install Node.js 20.19.0+ or 24.7.0+ (see `.nvmrc` for current version: 24.7.0) 11 + - Install Node.js (see `.nvmrc` for recommended version) 12 12 - Install pnpm globally: `npm install -g pnpm@10.15.1` 13 13 - Clone the repository and run setup commands 14 14 ··· 193 193 194 194 The repository uses GitHub Actions (`.github/workflows/ci.yml`): 195 195 196 - - Tests on multiple Node.js versions (20.19.0, 22.12.0, 24.7.0) 196 + - Tests on multiple Node.js versions 197 197 - Tests on multiple OS (macOS, Ubuntu, Windows) 198 198 - Runs build, lint, typecheck, and test commands 199 199 - Publishes preview packages on PRs
+9 -5
.github/workflows/ci.yml
··· 18 18 strategy: 19 19 matrix: 20 20 os: [macos-latest, ubuntu-latest, windows-latest] 21 - node-version: ['20.19.0', '22.12.0', '24.7.0'] 21 + node-version: ['20.19.0', '22.12.0', '24.10.0'] 22 22 steps: 23 23 - uses: actions/checkout@v4.2.2 24 24 with: ··· 38 38 run: pnpm build --filter="@hey-api/**" 39 39 40 40 - name: Build examples 41 - if: matrix.node-version == '24.7.0' && matrix.os == 'ubuntu-latest' 41 + if: matrix.node-version == '24.10.0' && matrix.os == 'ubuntu-latest' 42 42 run: pnpm build --filter="@examples/**" 43 43 44 44 - name: Run linter ··· 47 47 - name: Run type check 48 48 run: pnpm typecheck 49 49 50 - - name: Run unit tests 51 - run: pnpm test 50 + - name: Test packages 51 + run: pnpm test --filter="@hey-api/**" --filter="@test/**" 52 + 53 + - name: Test examples 54 + if: matrix.node-version == '24.10.0' && matrix.os == 'ubuntu-latest' 55 + run: pnpm test --filter="@examples/**" 52 56 53 57 - name: Publish preview packages 54 - if: github.event_name == 'pull_request' && matrix.node-version == '24.7.0' && matrix.os == 'ubuntu-latest' 58 + if: github.event_name == 'pull_request' && matrix.node-version == '24.10.0' && matrix.os == 'ubuntu-latest' 55 59 run: ./scripts/publish-preview-packages.sh 56 60 env: 57 61 TURBO_SCM_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
+1 -1
.github/workflows/coverage.yml
··· 21 21 strategy: 22 22 matrix: 23 23 os: [ubuntu-latest] 24 - node-version: ['24.7.0'] 24 + node-version: ['24.10.0'] 25 25 steps: 26 26 - uses: actions/checkout@v4.2.2 27 27
+1 -1
.github/workflows/release.yml
··· 21 21 strategy: 22 22 matrix: 23 23 os: [ubuntu-latest] 24 - node-version: ['24.7.0'] 24 + node-version: ['24.10.0'] 25 25 steps: 26 26 - uses: actions/checkout@v4.2.2 27 27
+1 -1
package.json
··· 32 32 "test:coverage": "turbo run test:coverage", 33 33 "test:update": "turbo run test:update", 34 34 "test:watch": "turbo run test:watch", 35 - "test": "turbo run test", 35 + "test": "turbo run test --filter=\"!@example/openapi-ts-sample\"", 36 36 "typecheck": "turbo run typecheck --filter=\"!@example/openapi-ts-sample\"" 37 37 }, 38 38 "engines": {
+1 -2
packages/openapi-ts-tests/main/test/openapi-ts.config.ts
··· 77 77 // 'https://somefakedomain.com/openapi.yaml', 78 78 ], 79 79 logs: { 80 - // level: 'debug', 81 - level: 'silent', 80 + level: 'debug', 82 81 path: './logs', 83 82 }, 84 83 // name: 'foo',
-73
packages/openapi-ts-tests/main/test/performance.test.ts
··· 1 - import path from 'node:path'; 2 - 3 - import { createClient, Logger } from '@hey-api/openapi-ts'; 4 - import { beforeEach, describe, expect, it } from 'vitest'; 5 - 6 - import { getSpecsPath } from '../../utils'; 7 - 8 - const V3_SPEC_PATH = path.resolve(getSpecsPath(), 'v3.json'); 9 - const V3_1_X_SPEC_PATH = path.resolve(getSpecsPath(), '3.1.x', 'full.yaml'); 10 - 11 - const toOutputPath = (name: string) => 12 - path.resolve(__dirname, 'generated', name); 13 - 14 - describe('performance', () => { 15 - beforeEach(() => { 16 - performance.clearMarks(); 17 - performance.clearMeasures(); 18 - }); 19 - 20 - it('creates client under 1500ms', async () => { 21 - const logger = new Logger(); 22 - await createClient( 23 - { 24 - input: V3_SPEC_PATH, 25 - logs: { 26 - level: 'silent', 27 - }, 28 - output: toOutputPath('perf'), 29 - plugins: ['@hey-api/client-fetch'], 30 - }, 31 - logger, 32 - ); 33 - 34 - const duration = logger.report(false)?.duration ?? 9999; 35 - expect(duration).toBeLessThanOrEqual(1500); 36 - }); 37 - 38 - it('parses spec under 1500ms', async () => { 39 - const logger = new Logger(); 40 - await createClient( 41 - { 42 - input: V3_SPEC_PATH, 43 - logs: { 44 - level: 'silent', 45 - }, 46 - output: toOutputPath('perf'), 47 - plugins: ['@hey-api/client-fetch'], 48 - }, 49 - logger, 50 - ); 51 - 52 - const duration = logger.report(false)?.duration ?? 9999; 53 - expect(duration).toBeLessThanOrEqual(1500); 54 - }); 55 - 56 - it('parses spec under 1500ms (experimental)', async () => { 57 - const logger = new Logger(); 58 - await createClient( 59 - { 60 - input: V3_1_X_SPEC_PATH, 61 - logs: { 62 - level: 'silent', 63 - }, 64 - output: toOutputPath('perf'), 65 - plugins: ['@hey-api/client-fetch'], 66 - }, 67 - logger, 68 - ); 69 - 70 - const duration = logger.report(false)?.duration ?? 9999; 71 - expect(duration).toBeLessThanOrEqual(1500); 72 - }); 73 - });