अखंड

Sep 15 2020

इकाई परीक्षण करने के लिए जेस्ट-प्रीसेट-कोणीय का उपयोग करना, लेकिन एक चेतावनी मिली UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSONकि यह सुनिश्चित नहीं है कि त्रुटि क्या है, इस कारण से आवेदन अटक गया है और अन्य इकाई परीक्षण नहीं चल रहा है।

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

मुझे यकीन नहीं है कि नोड - चेतावनी-चेतावनी कैसे चलाई जाए। ऐसा लगता है कि यह एक क्रमांकन मुद्दा है, यहां तक ​​कि यह सिर्फ एक चेतावनी है लेकिन निश्चित नहीं है कि मुद्दा कहां है। क्या अपवाद खोजने का कोई बेहतर तरीका है

जवाब

16 JamesBarrett Dec 01 2020 at 05:32

साथ में जेस्ट चलाएं --detectOpenHandles। यह आपको दिखाएगा कि आपके परीक्षण की युक्ति में वास्तव में क्या गलत है। मेरे लिए, कोणीय सामग्री के आयात और सर्विस मोक्स गायब थे। आप को जोड़ने के लिए कहा जा सकता है BrowserAnimationsModule, जैसा कि नम्बी ने अपने उत्तर में बताया

package.json:

"test": "jest --detectOpenHandles"
SanJaisy Oct 12 2020 at 09:26

मुद्दा async ऑपरेशन के साथ था, इसलिए नीचे के साथ परीक्षण केस लिखना, मेरे लिए समस्या को हल करें

describe('DateSelectionComponent', () => {
  let component: DateSelectionComponent;
  let fixture: ComponentFixture<DateSelectionComponent>;

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [DateSelectionComponent, SafePipe],
      imports: [
        SharedModule,
        NgReduxTestingModule,
        RouterTestingModule.withRoutes([])
      ],
      providers: [
        {
          provide: PageAPIActions, useValue: { setPageState() { } }
        }
      ]
    }).compileComponents();
    fixture = TestBed.createComponent(DateSelectionComponent);
    component = fixture.componentInstance;

    // Don't use Object.defineProperty when assigning value to class properties
    component.page$ = of('value');
    component.page = { destination: 'value' };
    component.startDate = new NgbDate(2019, 2, 27);
    component.minDate = new NgbDate(2019, 2, 27);
    fixture.detectChanges();
  }));

  it('should create', () => {
    expect(component).toBeTruthy();
  });

  it('Should Match Snapshot', () => {
     expect(fixture.debugElement.nativeElement).toMatchSnapshot()
  });
});
AviKaminetzky Oct 23 2020 at 23:04

मेरी स्थिति HttpClientModuleमें, परीक्षण फ़ाइल में आयात न करने से गुप्त त्रुटि उत्पन्न हो गई थी । अधिक जानकारी यहाँ ।

NambiNRajan Nov 17 2020 at 13:33

किसी को याद करने में मदद करने के लिए मेरा जवाब जोड़ना। मेरे मामले में मैं आयात करने से चूक गया हूं

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

अलगाव में परीक्षण मामले में से एक को चलाने के दौरान ही समस्या को खोजने में सक्षम।