Skip to content

Commit 36ed219

Browse files
committed
chore: fix tanstack-query tests
1 parent 6d11737 commit 36ed219

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

packages/plugins/tanstack-query/tests/plugin.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ model Foo {
6565
useInfiniteFindManypost_Item({ where: { published: true } });
6666
useInfiniteFindManypost_Item(undefined, { enabled: true, getNextPageParam: () => null });
6767
console.log(queryKey);
68-
console.log(data?.pages[0][0].published);
68+
console.log(data?.pages[0]?.[0]?.published);
6969
console.log(data?.pageParams[0]);
7070
}
7171
@@ -97,6 +97,7 @@ ${sharedModel}
9797
copyDependencies: [path.resolve(__dirname, '../dist')],
9898
compile: true,
9999
extraSourceFiles: [reactAppSource],
100+
tscInitArgs: '--moduleResolution bundler --module esnext',
100101
}
101102
);
102103
});
@@ -130,12 +131,13 @@ ${sharedModel}
130131
useSuspenseInfiniteFindManypost_Item({ where: { published: true } });
131132
useSuspenseInfiniteFindManypost_Item(undefined, { getNextPageParam: () => null });
132133
console.log(queryKey);
133-
console.log(data?.pages[0][0].published);
134+
console.log(data?.pages[0]?.[0]?.published);
134135
console.log(data?.pageParams[0]);
135136
}
136137
`,
137138
},
138139
],
140+
tscInitArgs: '--moduleResolution bundler --module esnext',
139141
}
140142
);
141143
});
@@ -157,7 +159,7 @@ ${sharedModel}
157159
useInfiniteFindManypost_Item({ where: { published: true } }, { enabled: true, getNextPageParam: () => null });
158160
useInfiniteFindManypost_Item(undefined, { getNextPageParam: () => null });
159161
console.log(queryKey);
160-
console.log(data.value?.pages[0][0].published);
162+
console.log(data.value?.pages[0]?.[0]?.published);
161163
console.log(data.value?.pageParams[0]);
162164
}
163165
@@ -189,6 +191,7 @@ ${sharedModel}
189191
copyDependencies: [path.resolve(__dirname, '../dist')],
190192
compile: true,
191193
extraSourceFiles: [vueAppSource],
194+
tscInitArgs: '--moduleResolution bundler --module esnext',
192195
}
193196
);
194197
});
@@ -211,6 +214,7 @@ ${sharedModel}
211214
copyDependencies: [path.resolve(__dirname, '../dist')],
212215
compile: true,
213216
extraSourceFiles: [vueAppSource],
217+
tscInitArgs: '--moduleResolution bundler --module esnext',
214218
}
215219
);
216220
});
@@ -233,7 +237,7 @@ ${sharedModel}
233237
useInfiniteFindManypost_Item({ where: { published: true } });
234238
useInfiniteFindManypost_Item(undefined, { enabled: true, getNextPageParam: () => null });
235239
console.log(queryKey);
236-
console.log(data?.pages[0][0].published);
240+
console.log(data?.pages[0]?.[0]?.published);
237241
console.log(data?.pageParams[0]);
238242
}
239243
@@ -265,6 +269,7 @@ ${sharedModel}
265269
copyDependencies: [path.resolve(__dirname, '../dist')],
266270
compile: true,
267271
extraSourceFiles: [svelteAppSource],
272+
tscInitArgs: '--moduleResolution bundler --module esnext',
268273
}
269274
);
270275
});
@@ -287,6 +292,7 @@ ${sharedModel}
287292
copyDependencies: [path.resolve(__dirname, '../dist')],
288293
compile: true,
289294
extraSourceFiles: [svelteAppSource],
295+
tscInitArgs: '--moduleResolution bundler --module esnext',
290296
}
291297
);
292298
});

packages/plugins/tanstack-query/tests/portable.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ describe('Tanstack Query Plugin Portable Tests', () => {
4141
import { useFindUniqueUser } from './hooks';
4242
const { data } = useFindUniqueUser({ where: { id: 1 }, include: { posts: true } });
4343
console.log(data?.email);
44-
console.log(data?.posts[0].title);
44+
console.log(data?.posts[0]?.title);
4545
`,
4646
},
4747
],
48+
tscInitArgs: '--moduleResolution bundler --module esnext',
4849
}
4950
);
5051
});
@@ -101,10 +102,11 @@ console.log(data?.posts[0].title);
101102
import { useFindUniqueUser } from './hooks';
102103
const { data } = useFindUniqueUser({ where: { id: 1 }, include: { posts: true } });
103104
console.log(data?.email);
104-
console.log(data?.posts[0].title);
105+
console.log(data?.posts[0]?.title);
105106
`,
106107
},
107108
],
109+
tscInitArgs: '--moduleResolution bundler --module esnext',
108110
}
109111
);
110112
});
@@ -147,6 +149,7 @@ console.log(data?.createdAt);
147149
`,
148150
},
149151
],
152+
tscInitArgs: '--moduleResolution bundler --module esnext',
150153
}
151154
);
152155
});

packages/testtools/src/schema.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ export type SchemaLoadOptions = {
151151
prismaLoadPath?: string;
152152
prismaClientOptions?: object;
153153
generateNoCompile?: boolean;
154+
tscInitArgs?: string;
154155
};
155156

156157
const defaultOptions: SchemaLoadOptions = {
@@ -363,7 +364,7 @@ export function createProjectAndCompile(schema: string, options: SchemaLoadOptio
363364
if (opt.compile || opt.extraSourceFiles) {
364365
console.log('Compiling...');
365366

366-
run('npx tsc --init');
367+
run(`npx tsc --init ${opt.tscInitArgs}`);
367368

368369
// add generated '.zenstack/zod' folder to typescript's search path,
369370
// so that it can be resolved from symbolic-linked files

0 commit comments

Comments
 (0)