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

chore(graphql-server): switch to vitest #11296

Draft
wants to merge 7 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
1 change: 0 additions & 1 deletion packages/graphql-server/.babelrc.js

This file was deleted.

8 changes: 0 additions & 8 deletions packages/graphql-server/jest.config.js

This file was deleted.

8 changes: 4 additions & 4 deletions packages/graphql-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"build:types": "tsc --build --verbose ./tsconfig.json",
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx\" --ignore dist --exec \"yarn build\"",
"prepublishOnly": "NODE_ENV=production yarn build",
"test": "jest src",
"test:watch": "yarn test --watch"
"test": "vitest run",
"test:watch": "vitest"
},
"dependencies": {
"@babel/runtime-corejs3": "7.25.0",
Expand Down Expand Up @@ -57,10 +57,10 @@
"@types/lodash": "4.17.7",
"@types/uuid": "10.0.0",
"@whatwg-node/fetch": "0.9.20",
"jest": "29.7.0",
"jsonwebtoken": "9.0.2",
"tsx": "4.17.0",
"typescript": "5.5.4"
"typescript": "5.5.4",
"vitest": "2.0.5"
},
"gitHead": "3905ed045508b861b495f8d5630d76c7a157d8f1"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`configureGraphiQLPlayground when in development should configure the GraphiQL Playground when allowGraphiQL is not provided 1`] = `
exports[`configureGraphiQLPlayground > when in development > should configure the GraphiQL Playground when allowGraphiQL is not provided 1`] = `
{
"defaultQuery": "query Redwood {
redwood {
Expand All @@ -13,7 +13,7 @@ exports[`configureGraphiQLPlayground when in development should configure the Gr
}
`;

exports[`configureGraphiQLPlayground when in development should configure the GraphiQL Playground when allowGraphiQL is null 1`] = `
exports[`configureGraphiQLPlayground > when in development > should configure the GraphiQL Playground when allowGraphiQL is null 1`] = `
{
"defaultQuery": "query Redwood {
redwood {
Expand All @@ -26,7 +26,7 @@ exports[`configureGraphiQLPlayground when in development should configure the Gr
}
`;

exports[`configureGraphiQLPlayground when in development should configure the GraphiQL Playground when allowGraphiQL is true 1`] = `
exports[`configureGraphiQLPlayground > when in development > should configure the GraphiQL Playground when allowGraphiQL is true 1`] = `
{
"defaultQuery": "query Redwood {
redwood {
Expand All @@ -39,7 +39,7 @@ exports[`configureGraphiQLPlayground when in development should configure the Gr
}
`;

exports[`configureGraphiQLPlayground when in development should configure the GraphiQL Playground when allowGraphiQL is undefined 1`] = `
exports[`configureGraphiQLPlayground > when in development > should configure the GraphiQL Playground when allowGraphiQL is undefined 1`] = `
{
"defaultQuery": "query Redwood {
redwood {
Expand All @@ -52,7 +52,7 @@ exports[`configureGraphiQLPlayground when in development should configure the Gr
}
`;

exports[`configureGraphiQLPlayground when in development should configure the GraphiQL Playground when no config is provided 1`] = `
exports[`configureGraphiQLPlayground > when in development > should configure the GraphiQL Playground when no config is provided 1`] = `
{
"defaultQuery": "query Redwood {
redwood {
Expand All @@ -65,7 +65,7 @@ exports[`configureGraphiQLPlayground when in development should configure the Gr
}
`;

exports[`configureGraphiQLPlayground when not in development environment should configure the GraphiQL Playground when allowGraphiQL is true 1`] = `
exports[`configureGraphiQLPlayground > when not in development environment > should configure the GraphiQL Playground when allowGraphiQL is true 1`] = `
{
"defaultQuery": "query Redwood {
redwood {
Expand Down
7 changes: 4 additions & 3 deletions packages/graphql-server/src/__tests__/cors.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { APIGatewayProxyEvent, Context } from 'aws-lambda'
import { vi, describe, it, expect } from 'vitest'

import { createLogger } from '@redwoodjs/api/logger'

import { createGraphQLHandler } from '../functions/graphql'

jest.mock('../makeMergedSchema', () => {
const { makeExecutableSchema } = require('@graphql-tools/schema')
vi.mock('../makeMergedSchema', async () => {
const { makeExecutableSchema } = await import('@graphql-tools/schema')
// Return executable schema
return {
makeMergedSchema: () =>
Expand Down Expand Up @@ -46,7 +47,7 @@ jest.mock('../makeMergedSchema', () => {
}
})

jest.mock('../directives/makeDirectives', () => {
vi.mock('../directives/makeDirectives', () => {
return {
makeDirectivesForPlugin: () => [],
}
Expand Down
2 changes: 2 additions & 0 deletions packages/graphql-server/src/__tests__/graphiql.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, beforeAll, afterAll, it, expect } from 'vitest'

import { configureGraphiQLPlayground } from '../graphiql'

describe('configureGraphiQLPlayground', () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/graphql-server/src/__tests__/introspection.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, beforeAll, afterAll, it, expect } from 'vitest'

import { configureGraphQLIntrospection } from '../introspection'

describe('configureGraphQLIntrospection', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import gql from 'graphql-tag'
import { describe, it, test, expect } from 'vitest'

import type { DirectiveParams } from '..'
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { GraphQLResolveInfo } from 'graphql'
import { parse, graphql, GraphQLError } from 'graphql'
import gql from 'graphql-tag'
import { vi, describe, it, expect } from 'vitest'

import {
makeDirectivesForPlugin,
Expand All @@ -14,7 +15,7 @@ import type {
SdlGlobImports,
} from '../types'

jest.mock('@redwoodjs/project-config', () => {
vi.mock('@redwoodjs/project-config', () => {
return {
getConfig: () => {
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import gql from 'graphql-tag'
import { describe, it, expect } from 'vitest'

import { makeSubscriptions } from '../subscriptions/makeSubscriptions'
const countdownSchema = gql`
Expand Down
2 changes: 2 additions & 0 deletions packages/graphql-server/src/__tests__/mapRwCorsToYoga.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest'

import { mapRwCorsOptionsToYoga } from '../cors'

/** Yoga CORS Options looks like
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type { APIGatewayProxyEvent, Context } from 'aws-lambda'
import { vi, describe, it, expect } from 'vitest'

import { createLogger } from '@redwoodjs/api/logger'

import { createGraphQLHandler } from '../../functions/graphql'

jest.mock('../../makeMergedSchema', () => {
const { makeExecutableSchema } = require('@graphql-tools/schema')
vi.mock('../../makeMergedSchema', async () => {
const { makeExecutableSchema } = await import('@graphql-tools/schema')
const { context } = await import('@redwoodjs/context')

// Return executable schema
return {
Expand All @@ -27,7 +29,7 @@ jest.mock('../../makeMergedSchema', () => {
resolvers: {
Query: {
me: () => {
const globalContext = require('@redwoodjs/context').context
const globalContext = context as any
const currentUser = globalContext.currentUser

return {
Expand All @@ -44,7 +46,7 @@ jest.mock('../../makeMergedSchema', () => {
}
})

jest.mock('../../directives/makeDirectives', () => {
vi.mock('../../directives/makeDirectives', () => {
return {
makeDirectivesForPlugin: () => [],
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest'

import { context as globalContext, setContext } from '@redwoodjs/context'
import { getAsyncStoreInstance } from '@redwoodjs/context/dist/store'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { APIGatewayProxyEvent, Context } from 'aws-lambda'
import { vi, describe, it, expect } from 'vitest'

import { createLogger } from '@redwoodjs/api/logger'

import { createGraphQLHandler } from '../../functions/graphql'

jest.mock('../../makeMergedSchema', () => {
const { makeExecutableSchema } = require('@graphql-tools/schema')
vi.mock('../../makeMergedSchema', async () => {
const { makeExecutableSchema } = await import('@graphql-tools/schema')

// Return executable schema
return {
Expand All @@ -32,7 +33,7 @@ jest.mock('../../makeMergedSchema', () => {
}
})

jest.mock('../../directives/makeDirectives', () => {
vi.mock('../../directives/makeDirectives', () => {
return {
makeDirectivesForPlugin: () => [],
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { APIGatewayProxyEvent, Context } from 'aws-lambda'
import { vi, describe, expect, it } from 'vitest'

import { createLogger } from '@redwoodjs/api/logger'

import { createGraphQLHandler } from '../../functions/graphql'

jest.mock('../../makeMergedSchema', () => {
const { makeExecutableSchema } = require('@graphql-tools/schema')
vi.mock('../../makeMergedSchema', async () => {
const { makeExecutableSchema } = await import('@graphql-tools/schema')

// Return executable schema
return {
Expand All @@ -32,7 +33,7 @@ jest.mock('../../makeMergedSchema', () => {
}
})

jest.mock('../../directives/makeDirectives', () => {
vi.mock('../../directives/makeDirectives', () => {
return {
makeDirectivesForPlugin: () => [],
}
Expand Down
Loading
Loading