Skip to content

Commit

Permalink
Separate leaks tests (#1888)
Browse files Browse the repository at this point in the history
  • Loading branch information
enisdenjo authored Nov 1, 2022
1 parent a946cf0 commit 6563dbb
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
25 changes: 24 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions examples/hackernews/__integration-tests__/hackernews.spec.ts
Original file line number Diff line number Diff line change
@@ -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<Record<string, any>, 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()
Expand All @@ -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',
])
Expand Down
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 6563dbb

Please sign in to comment.