diff --git a/test/codegen-outdir.test.ts b/test/codegen-outdir.test.ts new file mode 100644 index 0000000..aa951fb --- /dev/null +++ b/test/codegen-outdir.test.ts @@ -0,0 +1,22 @@ +import { fileURLToPath } from 'node:url' +import { describe, expect, it } from 'vitest' +import { $fetch, setup } from '@nuxt/test-utils/e2e' + +describe('urql', async () => { + await setup({ + rootDir: fileURLToPath(new URL('./fixtures/codegen-outdir', import.meta.url)), + }) + + it('useQuery and useAsyncQuery', async () => { + const html = await $fetch('/hello') + expect(html).toContain('AsyncQuery: hello, one') + expect(html).toContain('Query: hello, two') + expect(html).toContain('AsyncWithGettersQuery: hello, three') + expect(html).toContain('AsyncWithComputedQuery: hello, four') + }) + + it('useMutation', async () => { + const html = await $fetch('/again') + expect(html).toContain('Mutation: hello two from mutation') + }) +}) diff --git a/test/fixtures/codegen-outdir/app.vue b/test/fixtures/codegen-outdir/app.vue new file mode 100644 index 0000000..2b1be09 --- /dev/null +++ b/test/fixtures/codegen-outdir/app.vue @@ -0,0 +1,5 @@ + diff --git a/test/fixtures/codegen-outdir/nuxt.config.ts b/test/fixtures/codegen-outdir/nuxt.config.ts new file mode 100644 index 0000000..9041f94 --- /dev/null +++ b/test/fixtures/codegen-outdir/nuxt.config.ts @@ -0,0 +1,18 @@ +export default defineNuxtConfig({ + modules: ['../../../src/module'], + urqlClient: { + clients: { + hello: { + url: 'https://graphql-test.teages.xyz/graphql-hello', + credentials: 'include', + cookiesFilter: ['locale'], + fetchOptions: { + headers: { + Authorization: 'Bearer 123', + }, + }, + }, + }, + codegen: { outputDir: '.gql' }, + }, +}) diff --git a/test/fixtures/codegen-outdir/package.json b/test/fixtures/codegen-outdir/package.json new file mode 100644 index 0000000..dbdab15 --- /dev/null +++ b/test/fixtures/codegen-outdir/package.json @@ -0,0 +1,5 @@ +{ + "name": "basic", + "type": "module", + "private": true +} diff --git a/test/fixtures/codegen-outdir/pages/again.vue b/test/fixtures/codegen-outdir/pages/again.vue new file mode 100644 index 0000000..15c9a98 --- /dev/null +++ b/test/fixtures/codegen-outdir/pages/again.vue @@ -0,0 +1,13 @@ + + + diff --git a/test/fixtures/codegen-outdir/pages/hello.vue b/test/fixtures/codegen-outdir/pages/hello.vue new file mode 100644 index 0000000..615b87c --- /dev/null +++ b/test/fixtures/codegen-outdir/pages/hello.vue @@ -0,0 +1,22 @@ + + +