web-dev-qa-db-fra.com

Non délavéPromiserEakeServine: TypeError: Conversion de la structure circulaire à JSON avec JEST + Angular=

Utilisation de la Jest-Preset-angular pour effectuer le test de l'unité, mais obtient un avertissement comme UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON Je ne sais pas ce qui cause l'erreur, en raison de cette application, il est bloqué et n'exécute pas l'autre test d'unité.

PASS  src/app/pages/result/result-filter/result-filter.component.spec.ts (6.251 s)
 PASS  src/app/pages/result/search-navigation/search-navigation.component.spec.ts
 PASS  src/app/pages/result/filter-modal/filter-modal.component.spec.ts (5.699 s)
 PASS  src/app/app.component.spec.ts
 PASS  src/app/pages/test-type/test-type.component.spec.ts (12.857 s)
(node:3280) UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    |     property 'element' -> object with constructor 'Object'
    |     property 'componentProvider' -> object with constructor 'Object'
    --- property 'parent' closes the circle
    at stringify (<anonymous>)
    at writeChannelMessage (internal/child_process/serialization.js:117:20)
    at process.target._send (internal/child_process.js:808:17)
    at process.target.send (internal/child_process.js:706:19)
    at reportSuccess (/Users/macbook/Projects/Playtime Projects/IDP/Idp.Bx.Ui/idp/node_modules/jest-worker/build/workers/processChild.js:67:11)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:3280) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3280) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:3281) UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    |     property 'element' -> object with constructor 'Object'
    |     property 'componentProvider' -> object with constructor 'Object'
    --- property 'parent' closes the circle
    at stringify (<anonymous>)
    at writeChannelMessage (internal/child_process/serialization.js:117:20)
    at process.target._send (internal/child_process.js:808:17)
    at process.target.send (internal/child_process.js:706:19)
    at reportSuccess (/Users/macbook/Projects/Playtime Projects/IDP/Idp.Bx.Ui/idp/node_modules/jest-worker/build/workers/processChild.js:67:11)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:3281) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3281) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:3279) UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    |     property 'element' -> object with constructor 'Object'
    |     property 'componentProvider' -> object with constructor 'Object'
    --- property 'parent' closes the circle
    at stringify (<anonymous>)
    at writeChannelMessage (internal/child_process/serialization.js:117:20)
    at process.target._send (internal/child_process.js:808:17)
    at process.target.send (internal/child_process.js:706:19)
    at reportSuccess (/Users/macbook/Projects/Playtime Projects/IDP/Idp.Bx.Ui/idp/node_modules/jest-worker/build/workers/processChild.js:67:11)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:3279) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3279) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

 RUNS  src/app/pages/location/location.component.spec.ts
 RUNS  src/app/pages/signup/signup.component.spec.ts
 RUNS  src/app/pages/login/login.component.spec.ts

Test Suites: 10 passed, 10 of 20 total
Tests:       16 passed, 16 total
Snapshots:   1 obsolete, 5 passed, 5 total
Time:        2180 s

Je ne sais pas comment exécuter les avertissements de noeuds. On dirait que c'est une question de sérialisation, même ce n'est qu'un avertissement, mais pas sûr d'où est le problème. Y a-t-il un meilleur moyen de trouver l'exception

29
San Jaisy

Ajout de ma réponse pour aider quelqu'un si manqué. Dans mon cas, j'ai manqué d'importer

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

Capable de trouver le problème uniquement lors de l'exécution de l'un des cas de test isolément.

0
Nambi N Rajan