Skip to content

test: move tanstack query tests to a separate folder#3825

Merged
mrlubos merged 2 commits intomainfrom
refactor/test-tanstack-query
Apr 27, 2026
Merged

test: move tanstack query tests to a separate folder#3825
mrlubos merged 2 commits intomainfrom
refactor/test-tanstack-query

Conversation

@mrlubos
Copy link
Copy Markdown
Member

@mrlubos mrlubos commented Apr 26, 2026

No description provided.

@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hey-api-docs Ready Ready Preview, Comment Apr 27, 2026 9:27am

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 26, 2026

⚠️ No Changeset found

Latest commit: 8d89cae

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@mrlubos mrlubos marked this pull request as ready for review April 26, 2026 02:35
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. internal ⚙️ Internal development work. labels Apr 26, 2026
@mrlubos mrlubos force-pushed the refactor/test-tanstack-query branch from 9dcb906 to 3dc2c36 Compare April 26, 2026 02:36
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.57%. Comparing base (f3b6ff3) to head (8d89cae).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3825   +/-   ##
=======================================
  Coverage   39.57%   39.57%           
=======================================
  Files         532      532           
  Lines       19544    19544           
  Branches     5811     5811           
=======================================
  Hits         7734     7734           
  Misses       9568     9568           
  Partials     2242     2242           
Flag Coverage Δ
unittests 39.57% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pullfrog
Copy link
Copy Markdown
Contributor

pullfrog Bot commented Apr 26, 2026

TL;DR — Extracts all TanStack Query plugin tests from the main test package into a dedicated @test/openapi-ts-tanstack-query-v5 sub-package, isolating the six @tanstack/* dependencies so the main test suite no longer carries them.

Key changes

  • Create @test/openapi-ts-tanstack-query-v5 sub-package — New workspace package at packages/openapi-ts-tests/tanstack-query/v5/ with its own package.json, tsconfig.json, turbo.json, vitest setup, and test infrastructure (constants.ts, utils.ts, globalTeardown.ts).
  • Move TanStack Query scenarios out of main tests — 25 plugin scenarios (fetch, axios, class-based, name-builder, useMutation across all 6 TanStack frameworks) removed from main/test/plugins.test.ts; version-specific scenarios (internal-name-conflict, pagination-ref, sse-tanstack-react-query) removed from main/test/3.0.x.test.ts and main/test/3.1.x.test.ts.
  • Relocate ~2,760 snapshot files — Generated snapshots moved from the main test tree to tanstack-query/v5/__snapshots__/ and tanstack-query/v5/test/__snapshots__/.
  • Remove @tanstack/* dependencies from main package — Six @tanstack/* packages removed from main/package.json and added to the new sub-package instead.
  • Register new vitest workspace project — Root vitest.config.ts gains a workspace entry for @test/openapi-ts-tanstack-query-v5 with its own global teardown and setup files.
  • Lift custom plugin tests out of version loop — The custom plugin describe block in main/test/plugins.test.ts is now top-level instead of nested inside the for (version of versions) loop.

Summary | 2775 files | 1 commit | base: mainrefactor/test-tanstack-query


New TanStack Query test sub-package

Before: TanStack Query tests lived in packages/openapi-ts-tests/main/, requiring all six @tanstack/* framework dependencies in the main test package.
After: A dedicated @test/openapi-ts-tanstack-query-v5 package at packages/openapi-ts-tests/tanstack-query/v5/ owns the TanStack dependencies and all related test scenarios.

The new package includes its own test infrastructure: createConfigFactory in utils.ts builds configs from an OpenAPI version and output directory, constants.ts defines snapshot and temp directories, and globalTeardown.ts cleans up the temp directory after runs. The vitest.setup.ts sets the working directory via process.chdir.

Why version the path as v5? The v5 directory corresponds to TanStack Query v5 — the currently supported major version. This structure allows adding v6 (or other versions) alongside it in the future without path conflicts.

packages/openapi-ts-tests/tanstack-query/v5/package.json · tanstack-query/v5/test/utils.ts · vitest.config.ts


Test scenarios relocated from main

Before: main/test/plugins.test.ts contained 25+ TanStack Query scenarios alongside non-TanStack plugin tests; 3.0.x.test.ts and 3.1.x.test.ts each had TanStack-specific version scenarios.
After: All TanStack Query scenarios live in the new sub-package's 3.0.x.test.ts, 3.1.x.test.ts, and plugins.test.ts. The main test files retain only non-TanStack scenarios.

The relocated scenarios cover all six TanStack frameworks (angular-query-experimental, preact-query, react-query, solid-query, svelte-query, vue-query) across four configurations: Fetch API client, Axios client, class-based SDKs, and custom name builders. The custom plugin tests (non-TanStack) remain in main but are lifted out of the version loop to become top-level.

main/test/plugins.test.ts · tanstack-query/v5/test/3.1.x.test.ts · main/package.json

Pullfrog  | View workflow run | via Pullfrog𝕏

Copy link
Copy Markdown
Contributor

@pullfrog pullfrog Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Two non-critical issues: a shallow getFilePaths that diverges from the shared recursive version, and a duplicated custom plugin test block.

Clean extraction overall — dependencies, vitest project registration, turbo override, and workspace inclusion all look correct. The custom plugin describe block being moved out of the version for loop in main/test/plugins.test.ts is a good fix (it was always testing 3.1.x input regardless of the loop variable).

Task list (5/5 completed)
  • Checkout PR and read the diff
  • Analyze major areas of change and high-risk areas
  • Investigate changes in detail
  • Self-critique and finalize comments
  • Submit review

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run𝕏

Comment on lines +46 to +59
function getFilePaths(output: string): string[] {
const dirPath = path.resolve(output);
if (!fs.existsSync(dirPath)) {
return [];
}

return fs.readdirSync(dirPath).flatMap((dirent) => {
const filePath = path.join(dirPath, dirent);
if (fs.statSync(filePath).isDirectory()) {
return fs.readdirSync(filePath).map((file) => path.join(filePath, file));
}
return [filePath];
});
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This inline getFilePaths only traverses 2 levels deep (top-level entries + one subdirectory), while every other test package — including plugins.test.ts and meta-function.test.ts in this same directory — imports the shared fully-recursive getFilePaths from ../../../utils. The shallow version could silently miss files if the output structure ever nests deeper than 2 levels.

Consider importing from the shared utility instead:

import { getFilePaths } from '../../../utils';

The same applies to 3.1.x.test.ts.

Comment on lines +449 to +502
}

describe('custom plugin', () => {
it('handles a custom plugin', async () => {
const myPlugin: DefinePlugin<{
customOption: boolean;
name: any;
}>['Config'] = {
api: undefined,
config: {
customOption: true,
},
dependencies: ['@hey-api/typescript'],
handler: vi.fn(),
name: 'my-plugin',
};

await createClient({
input: path.join(getSpecsPath(), '3.1.x', 'full.yaml'),
logs: {
level: 'silent',
},
output: path.join(__dirname, 'generated', 'my-plugin', 'default'),
plugins: [myPlugin, '@hey-api/client-fetch'],
});

expect(myPlugin.handler).toHaveBeenCalled();
});

it.skip('throws on invalid dependency', async () => {
const myPlugin: DefinePlugin<{
name: any;
}>['Config'] = {
api: undefined,
config: {},
dependencies: ['@hey-api/oops'],
handler: vi.fn(),
name: 'my-plugin',
};

await expect(() =>
createClient({
input: path.join(getSpecsPath(), '3.1.x', 'full.yaml'),
logs: {
level: 'silent',
},
output: path.join(__dirname, 'generated', 'my-plugin', 'default'),
plugins: [myPlugin, '@hey-api/client-fetch'],
}),
).rejects.toThrowError(/Found 1 configuration error./g);

expect(myPlugin.handler).not.toHaveBeenCalled();
});
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This custom plugin describe block is identical to the one in main/test/plugins.test.ts (lines 231–282). These tests exercise the generic DefinePlugin API — they have no TanStack Query dependency — so they'll now run in both vitest projects. Consider keeping them only in main and removing them from here to avoid the duplication.

@pullfrog
Copy link
Copy Markdown
Contributor

pullfrog Bot commented Apr 26, 2026

TL;DR — Extracts all TanStack Query v5 plugin tests and their snapshots from the monolithic main test package into a dedicated packages/openapi-ts-tests/tanstack-query/v5/ workspace, isolating TanStack-specific dependencies and consolidating per-framework scenarios into combined test cases.

Key changes

  • Extract TanStack Query plugin tests into tanstack-query/v5 — All TanStack Query test scenarios (fetch, axios, asClass, name-builder, full-config across 6 frameworks) plus version-specific tests from 3.0.x.test.ts and 3.1.x.test.ts are moved from main/ to a new tanstack-query/v5/ workspace, with previously separate per-framework scenarios consolidated into single tests that generate all 6 at once.
  • Create new @test/openapi-ts-tanstack-query-v5 workspace package — Standalone package.json with its own TanStack Query dependencies (@tanstack/{angular-query-experimental,preact-query,react-query,solid-query,svelte-query,vue-query}), axios, and typescript.
  • Register new Vitest workspace project — Root vitest.config.ts gains a new workspace entry pointing to packages/openapi-ts-tests/tanstack-query/v5 with its own setup and global teardown files.
  • Move custom plugin tests and restructure main/test/plugins.test.ts — The custom plugin describe block is moved to the new workspace; the remaining main plugins.test.ts is restructured with custom plugin tests moved outside the version loop and using __dirname for output paths.
  • Add shared test infrastructure — New test/utils.ts with a createConfigFactory helper, test/constants.ts for path constants, vitest.setup.ts / globalTeardown.ts for test lifecycle management, plus tsconfig.json and turbo.json.
  • Refactor meta-function.test.ts — Simplified to use the new createConfigFactory and shared constants, removing manual __dirname computation.
  • Refactor utils.ts to use function declarations — Arrow function exports in packages/openapi-ts-tests/utils.ts changed to named function declarations.
  • Relocate ~1,380 snapshot files — Generated snapshot directories for all TanStack Query test scenarios across OpenAPI 2.0.x, 3.0.x, and 3.1.x are moved under the new tanstack-query/v5/ tree.

Summary | 1399 files | 1 commit | base: mainrefactor/test-tanstack-query


TanStack Query tests extracted to standalone workspace

Before: TanStack Query plugin tests lived in packages/openapi-ts-tests/main/, requiring all 6 @tanstack/* dependencies in its package.json alongside unrelated plugin tests. Each framework had separate test scenarios (e.g., 6 individual "generate Fetch API client" tests).
After: A new packages/openapi-ts-tests/tanstack-query/v5/ workspace package owns all TanStack Query test scenarios, dependencies, snapshots, and utilities. Per-framework scenarios are consolidated — one test generates all 6 framework plugins at once.

The new package includes a createConfigFactory helper in test/utils.ts that handles input arrays and object-style configs, path constants in test/constants.ts, a vitest.setup.ts that sets the working directory, and a globalTeardown.ts that cleans up the .tmp directory. The useMutation scenario is renamed to full-config in the new workspace.

What test scenarios moved?
  • 6 Fetch API client variants (one per TanStack framework, now consolidated into one test)
  • 6 Axios client variants (consolidated)
  • 6 class-based SDK variants (asClass + classNameBuilder, consolidated)
  • 6 custom name-builder variants (infiniteQueryKeys, queryOptions, etc., consolidated)
  • 1 full-config variant (previously useMutation@tanstack/react-query with setQueryData, useQuery, useSetQueryData)
  • custom plugin tests (handles a custom plugin, throws on invalid dependency)
  • 1 internal-name-conflict scenario for OpenAPI 3.0.x
  • 3 scenarios for OpenAPI 3.1.x (internal-name-conflict, pagination-ref, SSE POST exclusion)

tanstack-query/v5/package.json · tanstack-query/v5/test/plugins.test.ts · tanstack-query/v5/test/utils.ts · main/test/plugins.test.ts · vitest.config.ts

Pullfrog  | View workflow run | via Pullfrog𝕏

Copy link
Copy Markdown
Contributor

@pullfrog pullfrog Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incremental changes are lockfile-only (adds axios to the tanstack-query/v5 package and deduplicates lockfile entries). No new issues.

Task list (5/5 completed)
  • Checkout PR and read the diff
  • Analyze major areas of change and high-risk areas
  • Investigate changes in detail
  • Self-critique and finalize comments
  • Submit review

Pullfrog  | View workflow run𝕏

@mrlubos
Copy link
Copy Markdown
Member Author

mrlubos commented Apr 27, 2026

@pullfrog can you figure out why the Windows test suddenly fails and fix it?

@pullfrog
Copy link
Copy Markdown
Contributor

pullfrog Bot commented Apr 27, 2026

The Windows CI failure was caused by vitest.setup.ts in the new tanstack-query/v5 package using new URL('.', import.meta.url).pathname for process.chdir(). On Windows, .pathname produces a POSIX-style path with a leading slash before the drive letter (e.g. /D:/a/...), which is invalid. Fixed by using fileURLToPath() from node:url — matching every other vitest.setup.ts in the repo. All 4 tanstack-query test files pass locally after the fix.

Task list (5/5 completed)
  • Diagnose the Windows test failure (ENOENT on chdir with URL pathname)
  • Fix vitest.setup.ts to use fileURLToPath
  • Verify similar patterns in other test setup files
  • Verify the fix locally by running tests
  • Commit and push the fix

Pullfrog  | View workflow run | via Pullfrog𝕏

@mrlubos mrlubos merged commit 460e71c into main Apr 27, 2026
11 checks passed
@mrlubos mrlubos deleted the refactor/test-tanstack-query branch April 27, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal ⚙️ Internal development work. size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant