diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1c249db680..d675dcf033 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,30 @@ jobs: run: pnpm build - name: Run Tests - run: pnpm test:integration --ci + run: pnpm test:integration + + leaks: + name: leaks / nodejs v${{ matrix.node-version }} + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [14, 16, 18] + fail-fast: false + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - uses: the-guild-org/shared-config/setup@main + name: setup env + with: + nodeVersion: ${{ matrix.node-version }} + packageManager: pnpm + + - name: Build Packages + run: pnpm build + + - name: Run Tests + run: pnpm test:leaks esm: runs-on: ubuntu-latest diff --git a/examples/hackernews/__integration-tests__/hackernews.spec.ts b/examples/hackernews/__integration-tests__/hackernews.spec.ts index 7dc682bd1b..690cc25ea0 100644 --- a/examples/hackernews/__integration-tests__/hackernews.spec.ts +++ b/examples/hackernews/__integration-tests__/hackernews.spec.ts @@ -1,16 +1,20 @@ +import path from 'path' import { DbDrop, MigrateDev } from '@prisma/migrate' import { PrismaClient } from '@prisma/client' import { createYoga, YogaServerInstance } from 'graphql-yoga' import { schema } from '../src/schema' import type { GraphQLContext } from '../src/context' -describe.skip('hackernews example integration', () => { +describe('hackernews example integration', () => { let yoga: YogaServerInstance, GraphQLContext> beforeAll(async () => { const { createContext } = await import('../src/context') yoga = createYoga({ schema, context: createContext }) + // migrate - await MigrateDev.new().parse([]) + await MigrateDev.new().parse([ + `--schema=${path.resolve(__dirname, '..', 'prisma', 'schema.prisma')}`, + ]) // seed const client = new PrismaClient() @@ -26,6 +30,7 @@ describe.skip('hackernews example integration', () => { afterAll(async () => { // drop await DbDrop.new().parse([ + `--schema=${path.resolve(__dirname, '..', 'prisma', 'schema.prisma')}`, '--preview-feature', // DbDrop is an experimental feature '--force', ]) diff --git a/jest.config.js b/jest.config.js index 060ffee935..d6758141fc 100644 --- a/jest.config.js +++ b/jest.config.js @@ -29,6 +29,11 @@ if (process.env.INTEGRATION_TEST === 'true') { ) } +// tests that leak due to external dependencies +if (process.env.LEAKS_TEST === 'true') { + testMatch.push('!**/hackernews.spec.ts') +} + testMatch.push('!**/dist/**', '!**/.bob/**') module.exports = { diff --git a/package.json b/package.json index 02903e038f..2d462ca745 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,9 @@ "prebuild": "rimraf packages/*/dist", "check": "pnpm -r --filter=!example-deno run check", "build": "pnpm --filter=@graphql-yoga/graphiql run build && pnpm --filter=@graphql-yoga/render-graphiql run build && pnpm --filter=graphql-yoga run generate-graphiql-html && bob build", - "test": "jest --detectOpenHandles --detectLeaks", - "test:integration": "cross-env INTEGRATION_TEST=true jest --detectLeaks --logHeapUsage --forceExit", + "test": "jest --detectOpenHandles", + "test:integration": "cross-env INTEGRATION_TEST=true jest --forceExit", + "test:leaks": "LEAKS_TEST=true pnpm test --detectLeaks --logHeapUsage; LEAKS_TEST=true pnpm test:integration --detectLeaks --logHeapUsage", "release": "pnpm build && changeset publish", "start:docs": "pnpm --filter=website dev", "postinstall": "husky install",