snapshot of https://github.com/TanStack/query.git (main, 2026-09-16; blobs > 131072B omitted)
Some checks failed
autofix.ci / autofix (push) Failing after 4s
Release / Release (push) Has been skipped
GitHub Actions Security Analysis / Run zizmor (push) Failing after 2s

This commit is contained in:
upstream-mirror
2026-09-16 01:13:08 +05:00
commit 3a013ccdfe
3570 changed files with 490194 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
// @ts-check
import rootConfig from './root.eslint.config.js'
export default [...rootConfig]

View File

@@ -0,0 +1,44 @@
{
"name": "@tanstack/query-test-utils",
"version": "0.0.0",
"description": "Internal test utilities for TanStack Query",
"author": "Jonghyeon Ko <manudeli.ko@gmail.com>",
"private": true,
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/TanStack/query.git",
"directory": "packages/query-test-utils"
},
"homepage": "https://tanstack.com/query",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/tannerlinsley"
},
"main": "src/index.ts",
"types": "src/index.ts",
"module": "src/index.ts",
"exports": {
".": {
"types": "./src/index.ts",
"default": "./src/index.ts"
},
"./package.json": "./package.json"
},
"scripts": {
"clean": "premove ./build ./coverage ./dist-ts ./.cache/test-types",
"test:eslint": "eslint --concurrency=auto ./src",
"test:types": "npm-run-all --serial test:types:*",
"test:types:tscurrent": "tsc --project tsconfig.json --outDir .cache/test-types/tscurrent --tsBuildInfoFile .cache/test-types/tscurrent.tsbuildinfo",
"test:types:ts70": "node ../../node_modules/typescript70/lib/tsc.js --project tsconfig.json --outDir .cache/test-types/ts70 --tsBuildInfoFile .cache/test-types/ts70.tsbuildinfo",
"test:lib": "vitest",
"test:lib:dev": "pnpm run test:lib --watch"
},
"type": "module",
"devDependencies": {
"npm-run-all2": "^5.0.0"
},
"peerDependencies": {
"vitest": "^4.0.18"
}
}

View File

@@ -0,0 +1 @@
../../eslint.config.js

View File

@@ -0,0 +1,12 @@
import { describe, expect, it } from 'vitest'
import { queryKey } from '../queryKey'
describe('queryKey', () => {
it('should return a query key', () => {
const key = queryKey()
expect(key).toEqual(['query_1'])
})
it('should return a new query key each time', () => {
expect(queryKey()).not.toEqual(queryKey())
})
})

View File

@@ -0,0 +1,11 @@
import { describe, expect, it } from 'vitest'
import { sleep } from '../sleep'
describe('sleep', () => {
it('should sleep for the given amount of time', async () => {
const start = Date.now()
await sleep(100)
const end = Date.now()
expect(end - start).toBeGreaterThanOrEqual(100)
})
})

View File

@@ -0,0 +1,3 @@
export { sleep } from './sleep'
export { queryKey } from './queryKey'
export { mockVisibilityState } from './mockVisibilityState'

View File

@@ -0,0 +1,7 @@
import { vi } from 'vitest'
import type { MockInstance } from 'vitest'
export const mockVisibilityState = (
value: DocumentVisibilityState,
): MockInstance<() => DocumentVisibilityState> =>
vi.spyOn(document, 'visibilityState', 'get').mockReturnValue(value)

View File

@@ -0,0 +1,6 @@
let queryKeyCount = 0
export const queryKey = (): Array<string> => {
queryKeyCount++
return [`query_${queryKeyCount}`]
}

View File

@@ -0,0 +1,4 @@
export const sleep = (ms: number): Promise<void> =>
new Promise((resolve) => {
setTimeout(resolve, ms)
})

View File

@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist-ts",
"rootDir": "."
},
"include": ["src", "*.config.ts", "*.config.js", "package.json"]
}

View File

@@ -0,0 +1,29 @@
import { defineConfig } from 'vitest/config'
import packageJson from './package.json'
export default defineConfig({
// fix from https://github.com/vitest-dev/vitest/issues/6992#issuecomment-2509408660
resolve: {
conditions: ['@tanstack/custom-condition'],
},
environments: {
ssr: {
resolve: {
conditions: ['@tanstack/custom-condition'],
},
},
},
test: {
name: packageJson.name,
dir: './src',
watch: false,
coverage: {
enabled: !!process.env.CI,
provider: 'istanbul',
include: ['src/**/*'],
},
typecheck: { enabled: true },
restoreMocks: true,
},
})