Skip to content

Commit

Permalink
test: add test for graphql
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Feb 18, 2022
1 parent b66dd6d commit c333040
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 8 deletions.
23 changes: 23 additions & 0 deletions examples/graphql/package.json
@@ -0,0 +1,23 @@
{
"name": "@vitest/graphql",
"private": true,
"files": [
"dist",
"types"
],
"scripts": {
"coverage": "vitest run --coverage",
"dev": "vite",
"test": "vitest",
"test:ui": "vitest --ui"
},
"dependencies": {
"@rollup/plugin-graphql": "^1.1.0",
"graphql": "^16.3.0"
},
"devDependencies": {
"@vitest/ui": "latest",
"vite": "latest",
"vitest": "latest"
}
}
3 changes: 3 additions & 0 deletions examples/graphql/src/Fragment.gql
@@ -0,0 +1,3 @@
fragment CurrentUserFields on User {
id
}
7 changes: 7 additions & 0 deletions examples/graphql/src/Query.gql
@@ -0,0 +1,7 @@
#import "./Fragment.gql"

query Foo {
currentUser {
...CurrentUserFields
}
}
5 changes: 5 additions & 0 deletions examples/graphql/src/query.ts
@@ -0,0 +1,5 @@
import QUERY from './Query.gql'

export function getQuery() {
return QUERY
}
6 changes: 6 additions & 0 deletions examples/graphql/test/query.spec.ts
@@ -0,0 +1,6 @@
import { expect, test } from 'vitest'
import { getQuery } from '../src/query'

test('query is defined', () => {
expect(getQuery()).toBeDefined()
})
9 changes: 9 additions & 0 deletions examples/graphql/vite.config.ts
@@ -0,0 +1,9 @@
/// <reference types="vitest" />

import { defineConfig } from 'vite'
import graphql from '@rollup/plugin-graphql'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [graphql()],
})
56 changes: 48 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c333040

Please sign in to comment.