prisma-labs / graphql-framework-experiment

Code-First Type-Safe GraphQL Framework
https://nexusjs.org
MIT License
673 stars 66 forks source link

Parallel testing causes multiple servers on the same port, resulting in jest hanging and failing unpredictably #1422

Open MJGTwo opened 4 years ago

MJGTwo commented 4 years ago

Nexus Report

{
  "node": "v12.4.0",
  "os": {
    "platform": "darwin",
    "release": "19.6.0"
  },
  "nexus": "^0.26.1",
  "plugins": [
    "nexus-plugin-prisma",
    "nexus-plugin-jwt-auth",
    "nexus-plugin-shield"
  ],
  "otherDependencies": {
    "bcryptjs": "^2.4.3",
    "body-parser": "^1.19.0",
    "cors": "^2.8.5",
    "dotenv-cli": "^4.0.0",
    "jest-config": "^26.4.2",
    "jsonwebtoken": "^8.5.1"
  },
  "devDependencies": {
    "@types/bcryptjs": "^2.4.2",
    "@types/jsonwebtoken": "^8.5.0",
    "@typescript-eslint/eslint-plugin": "^4.1.1",
    "@typescript-eslint/parser": "^4.1.1",
    "babel-polyfill": "^6.26.0",
    "eslint": "^7.9.0",
    "eslint-config-prettier": "^6.11.0",
    "eslint-plugin-prettier": "^3.1.4",
    "jest": "^26.4.2",
    "jest-environment-node": "^26.3.0",
    "mysql": "^2.18.1",
    "nanoid": "^3.1.12",
    "supertest": "^4.0.2",
    "ts-jest": "^26.3.0",
    "typescript": "^4.0.2",
    "util": "^0.12.3"
  },
  "hasAppModule": true,
  "packageManager": "yarn",
  "errorsWhileGatheringReport": {
    "gettingLayout": null,
    "gettingPluginManifests": null
  }
}

Screenshot

Screen Shot 2020-09-21 at 1 32 53 PM

Description

When multiple test suites are ran in parallel, multiple instances of the server are spun up for the same port. This causes suites to unpredictably fail due to hanging for more than than the allotted time by the jest configuration. When ran with --runInBand this issue disappears due to servers being spun up one at a time.

Repro

https://github.com/MJGTwo/nexus-prisma-template