Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable vitest workspaces #3669

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 8
version: 9
run_install: false

- name: Get pnpm store directory
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 8
version: 9
run_install: false

- name: Get pnpm store directory
Expand Down Expand Up @@ -125,7 +125,7 @@ jobs:
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 8
version: 9
run_install: false

- name: Get pnpm store directory
Expand Down Expand Up @@ -180,7 +180,7 @@ jobs:
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 8
version: 9
run_install: false

- name: Get pnpm store directory
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 8
version: 9
run_install: false

- name: Get pnpm store directory
Expand Down
2 changes: 1 addition & 1 deletion examples/with-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@urql/core": "^5.0.6",
"@urql/svelte": "^4.2.1",
"graphql": "^16.6.0",
"svelte": "^4.0.5"
"svelte": "~5.0.0-next.202"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^2.4.2",
Expand Down
3 changes: 1 addition & 2 deletions exchanges/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@
},
"devDependencies": {
"@urql/core": "workspace:*",
"graphql": "^16.0.0",
"vitest": "^0.30.1"
"graphql": "^16.0.0"
},
"publishConfig": {
"access": "public",
Expand Down
3 changes: 1 addition & 2 deletions exchanges/context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
},
"devDependencies": {
"@urql/core": "workspace:*",
"graphql": "^16.0.0",
"vitest": "^0.30.1"
"graphql": "^16.0.0"
},
"publishConfig": {
"access": "public",
Expand Down
3 changes: 1 addition & 2 deletions exchanges/execute/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@
},
"devDependencies": {
"@urql/core": "workspace:*",
"graphql": "^16.0.0",
"vitest": "^0.30.1"
"graphql": "^16.0.0"
},
"publishConfig": {
"access": "public",
Expand Down
3 changes: 1 addition & 2 deletions exchanges/graphcache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@
"graphql": "^16.6.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"urql": "workspace:*",
"vitest": "^0.30.1"
"urql": "workspace:*"
},
"publishConfig": {
"access": "public",
Expand Down
14 changes: 7 additions & 7 deletions exchanges/graphcache/src/store/__snapshots__/store.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

exports[`Store with storage > should be able to persist embedded data 1`] = `
{
"Query%2eappointment({\\"id\\":\\"1\\"}).__typename": "\\"Appointment\\"",
"Query%2eappointment({\\"id\\":\\"1\\"}).info": "\\"urql meeting\\"",
"Query.appointment({\\"id\\":\\"1\\"})": ":\\"Query.appointment({\\\\\\"id\\\\\\":\\\\\\"1\\\\\\"})\\"",
"Query%2eappointment({"id":"1"}).__typename": ""Appointment"",
"Query%2eappointment({"id":"1"}).info": ""urql meeting"",
"Query.appointment({"id":"1"})": ":"Query.appointment({\\"id\\":\\"1\\"})"",
}
`;

exports[`Store with storage > should be able to store and rehydrate data 1`] = `
{
"Appointment:1.__typename": "\\"Appointment\\"",
"Appointment:1.id": "\\"1\\"",
"Appointment:1.info": "\\"urql meeting\\"",
"Query.appointment({\\"id\\":\\"1\\"})": ":\\"Appointment:1\\"",
"Appointment:1.__typename": ""Appointment"",
"Appointment:1.id": ""1"",
"Appointment:1.info": ""urql meeting"",
"Query.appointment({"id":"1"})": ":"Appointment:1"",
}
`;
4 changes: 2 additions & 2 deletions exchanges/graphcache/src/store/data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe('inspectFields', () => {
"arguments": {
"id": "1",
},
"fieldKey": "todo({\\"id\\":\\"1\\"})",
"fieldKey": "todo({"id":"1"})",
"fieldName": "todo",
},
{
Expand All @@ -166,7 +166,7 @@ describe('inspectFields', () => {
"arguments": {
"id": "1",
},
"fieldKey": "hasTodo({\\"id\\":\\"1\\"})",
"fieldKey": "hasTodo({"id":"1"})",
"fieldName": "hasTodo",
},
]
Expand Down
3 changes: 1 addition & 2 deletions exchanges/persisted/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@
},
"devDependencies": {
"@urql/core": "workspace:*",
"graphql": "^16.0.0",
"vitest": "^0.30.1"
"graphql": "^16.0.0"
},
"publishConfig": {
"access": "public",
Expand Down
3 changes: 1 addition & 2 deletions exchanges/populate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
},
"devDependencies": {
"@urql/core": "workspace:*",
"graphql": "^16.0.0",
"vitest": "^0.30.1"
"graphql": "^16.0.0"
},
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion exchanges/populate/src/populateExchange.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ describe('on query -> mutation', () => {
__typename
id
text
createdAt(timezone: \\"GMT+1\\")
createdAt(timezone: "GMT+1")
}
}"
`);
Expand Down
3 changes: 1 addition & 2 deletions exchanges/refocus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@
"devDependencies": {
"@types/react": "^17.0.4",
"@urql/core": "workspace:*",
"graphql": "^16.0.0",
"vitest": "^0.30.1"
"graphql": "^16.0.0"
},
"peerDependencies": {
"@urql/core": "^5.0.0"
Expand Down
3 changes: 1 addition & 2 deletions exchanges/request-policy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
},
"devDependencies": {
"@urql/core": "workspace:*",
"graphql": "^16.0.0",
"vitest": "^0.30.1"
"graphql": "^16.0.0"
},
"peerDependencies": {
"@urql/core": "^5.0.0"
Expand Down
3 changes: 1 addition & 2 deletions exchanges/retry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
},
"devDependencies": {
"@urql/core": "workspace:*",
"graphql": "^16.0.0",
"vitest": "^0.30.1"
"graphql": "^16.0.0"
},
"peerDependencies": {
"@urql/core": "^5.0.0"
Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"jsr": "pnpm --filter @urql/core jsr",
"jsr:dryrun": "pnpm --filter @urql/core jsr --dry-run"
},
"engines": {
"pnpm": "^9.0.0"
},
"eslintConfig": {
"root": true,
"extends": [
Expand Down Expand Up @@ -52,7 +55,6 @@
"react-dom": "^17.0.2",
"react-is": "^17.0.2",
"styled-components": "^5.2.3",
"vite": "^3.2.4",
"wonka": "^6.3.2"
}
},
Expand Down Expand Up @@ -105,10 +107,10 @@
"rollup-plugin-visualizer": "^5.9.0",
"tar": "^6.1.13",
"terser": "^5.17.1",
"typescript": "^5.1.6",
"vite": "^3.2.4",
"vite-tsconfig-paths": "^4.2.0",
"vitest": "^0.30.1"
"typescript": "^5.4.4",
"vite": "^5.4.4",
"vite-tsconfig-paths": "^4.0.0",
"vitest": "^2.1.0"
},
"dependencies": {
"@actions/github": "^5.1.1",
Expand Down
3 changes: 0 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,5 @@
"publishConfig": {
"access": "public",
"provenance": true
},
"devDependencies": {
"vitest": "^0.30.1"
}
}
2 changes: 1 addition & 1 deletion packages/core/src/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ describe('executeQuery', () => {
expect(true).toBeFalsy();
} catch (e: any) {
expect(e.message).toMatchInlineSnapshot(
`"Expected operation of type \\"query\\" but found \\"mutation\\""`
`"Expected operation of type "query" but found "mutation""`
);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,4 +460,4 @@ exports[`on success > returns response data 1`] = `
}
`;

exports[`on success > returns response data 2`] = `"{\\"operationName\\":\\"getUser\\",\\"query\\":\\"query getUser($name: String) {\\\\n user(name: $name) {\\\\n id\\\\n firstName\\\\n lastName\\\\n }\\\\n}\\",\\"variables\\":{\\"name\\":\\"Clara\\"}}"`;
exports[`on success > returns response data 2`] = `"{"operationName":"getUser","query":"query getUser($name: String) {\\n user(name: $name) {\\n id\\n firstName\\n lastName\\n }\\n}","variables":{"name":"Clara"}}"`;
4 changes: 2 additions & 2 deletions packages/core/src/gql.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { parse, print } from '@0no-co/graphql.web';
import { vi, expect, it, beforeEach, SpyInstance } from 'vitest';
import { vi, expect, it, beforeEach, MockInstance } from 'vitest';

Check failure on line 2 in packages/core/src/gql.test.ts

View workflow job for this annotation

GitHub Actions / Checks

Delete `·`

import { gql } from './gql';
import { keyDocument } from './utils';

let warn: SpyInstance;
let warn: MockInstance;

beforeEach(() => {
warn = vi.spyOn(console, 'warn');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -758,23 +758,7 @@ exports[`on success > uses the mock fetch if given 1`] = `
"results": [
{
"type": "return",
"value": {
"headers": {
"get": [Function],
},
"status": 200,
"text": [MockFunction spy] {
"calls": [
[],
],
"results": [
{
"type": "return",
"value": "{\\"status\\":200,\\"data\\":{\\"data\\":{\\"user\\":1200}}}",
},
],
},
},
"value": Promise {},
},
],
},
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/internal/fetchOptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
const body = makeFetchBody(queryOperation);
expect(makeFetchOptions(queryOperation, body)).toMatchInlineSnapshot(`
{
"body": "{\\"operationName\\":\\"getUser\\",\\"query\\":\\"query getUser($name: String) {\\\\n user(name: $name) {\\\\n id\\\\n firstName\\\\n lastName\\\\n }\\\\n}\\",\\"variables\\":{\\"name\\":\\"Clara\\"}}",
"body": "{"operationName":"getUser","query":"query getUser($name: String) {\\n user(name: $name) {\\n id\\n firstName\\n lastName\\n }\\n}","variables":{"name":"Clara"}}",
"headers": {
"accept": "application/graphql-response+json, application/graphql+json, application/json, text/event-stream, multipart/mixed",
"content-type": "application/json",
Expand All @@ -158,7 +158,7 @@

expect(makeFetchOptions(operation, body)).toMatchInlineSnapshot(`
{
"body": "{\\"operationName\\":\\"getUser\\",\\"query\\":\\"query getUser($name: String) {\\\\n user(name: $name) {\\\\n id\\\\n firstName\\\\n lastName\\\\n }\\\\n}\\",\\"variables\\":{\\"name\\":\\"Clara\\"}}",
"body": "{"operationName":"getUser","query":"query getUser($name: String) {\\n user(name: $name) {\\n id\\n firstName\\n lastName\\n }\\n}","variables":{"name":"Clara"}}",
"headers": {
"accept": "application/graphql-response+json, application/graphql+json, application/json, text/event-stream, multipart/mixed",
"content-type": "application/json",
Expand All @@ -180,7 +180,7 @@

expect(makeFetchOptions(operation, body)).toMatchInlineSnapshot(`
{
"body": "{\\"operationName\\":\\"getUser\\",\\"query\\":\\"query getUser($name: String) {\\\\n user(name: $name) {\\\\n id\\\\n firstName\\\\n lastName\\\\n }\\\\n}\\",\\"variables\\":{\\"name\\":\\"Clara\\"}}",
"body": "{"operationName":"getUser","query":"query getUser($name: String) {\\n user(name: $name) {\\n id\\n firstName\\n lastName\\n }\\n}","variables":{"name":"Clara"}}",
"headers": {
"accept": "application/graphql-response+json, application/graphql+json, application/json, text/event-stream, multipart/mixed",
"content-type": "application/json",
Expand Down Expand Up @@ -239,8 +239,8 @@
},
});

expect(form.get('map')).toMatchInlineSnapshot(

Check failure on line 242 in packages/core/src/internal/fetchOptions.test.ts

View workflow job for this annotation

GitHub Actions / Checks

Replace `⏎······`"{"0":["variables.file"]}"`⏎····` with ``"{"0":["variables.file"]}"``
'"{\\"0\\":[\\"variables.file\\"]}"'
`"{"0":["variables.file"]}"`
);
expect(form.get('0')).toBeInstanceOf(Blob);
});
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/utils/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ describe('stringifyDocument ', () => {
.toMatchInlineSnapshot(`
"{
field(arg:
\\"test #1\\")
"test #1")
}"
`);
});
Expand All @@ -197,10 +197,10 @@ describe('stringifyDocument ', () => {
.toMatchInlineSnapshot(`
"{
field(arg:
\\"\\"\\"
"""
hello
#hello
\\"\\"\\")
""")
}"
`);
});
Expand Down
1 change: 1 addition & 0 deletions packages/introspection/src/minifyIntrospectionQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const minifyIntrospectionType = (
};

case 'INPUT_OBJECT': {
// @ts-ignore TODO: add isOneOf support here
return {
kind: 'INPUT_OBJECT',
name: type.name,
Expand Down
4 changes: 4 additions & 0 deletions packages/introspection/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { mergeConfig } from 'vitest/config';
import baseConfig from '../../vitest.config';

export default mergeConfig(baseConfig, {});
1 change: 1 addition & 0 deletions packages/next-urql/src/useQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,6 @@ export function useQuery<

useUrqlValue(request.key);

// @ts-ignore Sorry what?
return [result, execute];
}
3 changes: 1 addition & 2 deletions packages/preact-urql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
"@testing-library/preact": "^2.0.0",
"@urql/core": "workspace:*",
"graphql": "^16.0.0",
"preact": "^10.13.0",
"vitest": "^0.30.1"
"preact": "^10.13.0"
},
"peerDependencies": {
"@urql/core": "^5.0.0",
Expand Down
11 changes: 10 additions & 1 deletion packages/preact-urql/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import { mergeConfig } from 'vitest/config';
import path from 'node:path';
import baseConfig from '../../vitest.config';

export default mergeConfig(baseConfig, {});
console.log(path.resolve(__dirname, './node_modules/preact/hooks/dist/hooks.js'));
export default mergeConfig(baseConfig, {
resolve: {
alias: {
'preact/hooks': path.resolve(__dirname, './node_modules/preact/hooks/dist/hooks.js'),
preact: path.resolve(__dirname, './node_modules/preact/dist/preact.js')
},
},
});
Loading
Loading