Шутка с кукловодом TypeError: невозможно создать свойство '_called' для числа '11' - PullRequest
1 голос
/ 03 августа 2020

Журнал ошибок теста:

 PASS  tests/header.test.js (8.099s)
  ✓ the header section has the correct text (2260ms)
  ✓ clicking login starts OAuth flow (2511ms)
  ✓ When signed in,  shows logout button (2851ms)


 RUNS  tests/blogs.test.js

Test Suites: 1 passed, 1 of 2 total
Tests:       3 passed, 3 total
Snapshots:   0 total
Time:        11s, estimated 38s
  console.error node_modules/jsdom/lib/jsdom/virtual-console.js:29
    Error: Uncaught [TypeError: Cannot create property '_called' on number '11']
        at reportException (/home/sh4d0w/Desktop/Node-Advance/AdvancedNodeStarter/node_modules/jsdom/lib/jsdom/living/helpers/runtime-script-errors.js:66:24)
        at Timeout.callback [as _onTimeout] (/home/sh4d0w/Desktop/Node-Advance/AdvancedNodeStarter/node_modules/jsdom/lib/jsdom/browser/Window.js:680:7)
        at listOnTimeout (internal/timers.js:549:17)
        at processTimers (internal/timers.js:492:7) TypeError: Cannot create property '_called' on number '11'
 FAIL  tests/blogs.test.js (11.265s)-Advance/AdvancedNodeStarter/node_modules/mo  when logged in
    ✓ can see blog create form (2923ms)
    And using valid inputs
      ✓ submitting take user to review screen (3365ms)
      ✓ submitting then saving adds blogs to index page (3635ms)
    And using invalid inputs
      ✕ the form shows an error message (842ms)

  ● when logged in › And using invalid inputs › the form shows an error message

    TypeError: Cannot create property '_called' on number '11'
      
      at node_modules/mongodb-core/lib/topologies/shared.js:224:25
      at Timeout.callback [as _onTimeout] (node_modules/jsdom/lib/jsdom/browser/Window.js:678:19)

Test Suites: 1 failed, 1 passed, 2 total
Tests:       1 failed, 6 passed, 7 total
Snapshots:   0 total
Time:        12.005s, estimated 38s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! server@1.0.0 test: `jest`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the server@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/sh4d0w/.npm/_logs/2020-08-03T07_48_03_329Z-debug.log

И когда я запускаю этот тест, на стороне сервера возникает эта ошибка узел с журналом сервера response dev:

[1] Compiled successfully!
[1] 
[1] You can now view client in the browser.
[1] 
[1]   Local:            http://localhost:3000/
[1]   On Your Network:  http://192.168.0.105:3000/
[1] 
[1] Note that the development build is not optimized.
[1] To create a production build, use npm run build.
[1] 
[1] Proxy error: Could not proxy request /api/blogs from localhost:3000 to http://localhost:5000.
[1] See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNRESET).
[1] 
[1] [HPM] Error occurred while trying to proxy request /api/blogs from localhost:3000 to http://localhost:5000 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
[1] Proxy error: Could not proxy request /api/blogs from localhost:3000 to http://localhost:5000.
[1] See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNRESET).
[1] 
[1] [HPM] Error occurred while trying to proxy request /api/blogs from localhost:3000 to http://localhost:5000 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
[1] Proxy error: Could not proxy request /api/blogs from localhost:3000 to http://localhost:5000.
[1] See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNRESET).
[1] 
[1] [HPM] Error occurred while trying to proxy request /api/blogs from localhost:3000 to http://localhost:5000 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
[0] [nodemon] restarting due to changes...
[0] [nodemon] starting `node index.js`
[0] [nodemon] restarting due to changes...
[0] [nodemon] starting `node index.js`
[0] Listening on port 5000

Пакет на стороне сервера. json файл

{
  "name": "server",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "jest": {
    "setupTestFrameworkScriptFile": "./tests/setup.js",
    "verbose": true,
    "testURL": "http://localhost/"
  },
  "scripts": {
    "start": "node index.js",
    "server": "nodemon index.js --ignore tests",
    "client": "npm run start --prefix client",
    "dev": "concurrently \"npm run server\" \"npm run client\"",
    "build": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client",
    "heroku-postbuild": "npm run build",
    "test": "jest"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "aws-sdk": "^2.188.0",
    "body-parser": "^1.17.2",
    "concurrently": "^3.5.0",
    "cookie-session": "^2.0.0-beta.2",
    "express": "^4.15.3",
    "jest": "^22.4.4",
    "migrate-mongoose": "^3.2.2",
    "mongoose": "^4.11.1",
    "nodemon": "^1.11.0",
    "passport": "^0.3.2",
    "passport-google-oauth20": "^2.0.0",
    "path-parser": "^2.0.2",
    "puppeteer": "^5.2.1",
    "redis": "^2.8.0",
    "uuid": "^3.2.1"
  }
}

пакет на стороне клиента. json файл

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "proxy": {
    "/auth/*": {
      "target": "http://localhost:5000"
    },
    "/api/*": {
      "target": "http://localhost:5000"
    }
  },
  "dependencies": {
    "axios": "^0.16.2",
    "materialize-css": "^0.100.2",
    "react": "^16.0.0-alpha.13",
    "react-dom": "^16.0.0-alpha.13",
    "react-redux": "^5.0.5",
    "react-router-dom": "^4.1.1",
    "react-scripts": "1.0.10",
    "redux": "^3.7.1",
    "redux-form": "^7.0.1",
    "redux-thunk": "^2.2.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

может кто-нибудь мне помочь, я пробовал много решений, но ни одно из них не сработало для меня: (

Если я откажусь от одного из test из всего теста внутри тестового файла, он работает нормально, и если я снова добавлю этот удаленный тест, может возникнуть ошибка, эта ошибка возникла из-за времени, может быть?

...