Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jest test suites failed to pass

The issue appears when I'm running all tests at once and every time the amount of failed test suites is different. When I'm running failed test suites separately tests pass successfully. Stack trace leads to node_modules dependencies. Here is a part of a jest log:



 FAIL  tests/unit/middleware/organization.middleware.test.js
  ● Test suite failed to run

    TypeError: Invalid URL: http://localhost

      at new URLImpl (node_modules/whatwg-url/dist/URL-impl.js:21:13)
      at Object.exports.setup (node_modules/whatwg-url/dist/URL.js:54:12)
      at new URL (node_modules/whatwg-url/dist/URL.js:107:22)
      at transformOptions (node_modules/jsdom/lib/api.js:235:38)
      at new JSDOM (node_modules/jsdom/lib/api.js:34:15)

 FAIL  tests/unit/services/logstash.service.test.js
● Test suite failed to run

    TypeError: Invalid URL: http://localhost

      at new URLImpl (node_modules/whatwg-url/dist/URL-impl.js:21:13)
      at Object.exports.setup (node_modules/whatwg-url/dist/URL.js:54:12)
      at new URL (node_modules/whatwg-url/dist/URL.js:107:22)
      at transformOptions (node_modules/jsdom/lib/api.js:235:38)
      at new JSDOM (node_modules/jsdom/lib/api.js:34:15)

I have the following dependencies installed:

  "dependencies": {
    "@xmpp/client": "^0.11.1",
    "accesscontrol": "^2.2.1",
    "bcryptjs": "^2.4.3",
    "cookie-parser": "~1.4.3",
    "cors": "^2.8.5",
    "debug": "^2.6.9",
    "express": "~4.16.0",
    "express-async-handler": "^1.1.4",
    "express-rate-limit": "^5.1.3",
    "express-validator": "^6.12.0",
    "geoip-lite": "^1.3.8",
    "got": "^11.5.1",
    "jsonwebtoken": "^8.5.1",
    "lodash": "^4.17.21",
    "log4js": "^6.3.0",
    "mongo-mock": "^4.0.0",
    "mongodb": "^3.2.7",
    "morgan": "~1.9.0",
    "node-cache": "^4.2.1",
    "node-schedule": "^1.3.2",
    "p-retry": "^4.2.0",
    "pako": "^1.0.11",
    "saslprep": "^1.0.3",
    "search-query-parser": "^1.5.4",
    "sinon": "^9.0.2"
  },
  "devDependencies": {
    "@types/jest": "^26.0.22",
    "eslint": "^7.24.0",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-jest": "^24.3.5",
    "jest": "^26.6.3",
    "jest-sonar-reporter": "^2.0.0",
    "mongodb-memory-server": "^6.9.6",
    "node-mocks-http": "^1.10.1",
    "nyc": "^14.1.1",
    "proxyquire": "^2.1.3",
    "randomstring": "^1.1.5",
    "rewire": "^5.0.0",
    "rewiremock": "^3.14.3",
    "supertest": "^6.1.3"
  },
  "jestSonar": {
    "reportFile": "test-results.xml"
  }
like image 593
Porbs Avatar asked Sep 06 '25 03:09

Porbs


1 Answers

To fix the issue I updated jest version to 27.0.6

like image 137
Porbs Avatar answered Sep 07 '25 21:09

Porbs