Jest-preset-angular: Jsdom 13 error connect ECONNREFUSED 127.0.0.1:80 even all test passed

Created on 18 Jul 2019  ·  19Comments  ·  Source: thymikee/jest-preset-angular

hi team.
I'm new to Jest and try to add it to my Angular app.
For now, all the test is passed but this error is repeatedly produced.
Seem like jest does not mock the http request or jsdom can not handle http mocking.
Can anyone help me out? I tried to research but can not find any solution.

console.error node_modules/jest-environment-jsdom-thirteen/node_modules/jsdom/lib/jsdom/virtual-console.js:29
    Error: Error: connect ECONNREFUSED 127.0.0.1:80
        at Object.dispatchError (D:\EMP-APP\node_modules\jest-environment-jsdom-thirteen\node_modules\jsdom\lib\jsdom\living\xhr-utils.js:60:19)
        at Request.client.on.err (D:\EMP-APP\node_modules\jest-environment-jsdom-thirteen\node_modules\jsdom\lib\jsdom\living\xmlhttprequest.js:674:20)
        at Request.emit (events.js:198:15)
        at Request.onRequestError (D:\EMP-APP\node_modules\request\request.js:881:8)
        at ClientRequest.emit (events.js:193:13)
        at Socket.socketErrorListener (_http_client.js:397:9)
        at Socket.emit (events.js:193:13)
        at emitErrorNT (internal/streams/destroy.js:91:8)
        at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
        at processTicksAndRejections (internal/process/task_queues.js:81:17) undefined

Most helpful comment

This is what I'm using for my jest.config.js file:

console.log('loading jest.config.js file');
module.exports = {
    preset: 'jest-preset-angular',
    setupFilesAfterEnv: ['<rootDir>/tests/client/jest-setup.ts'],
    globals: {
        'ts-jest': {
            tsConfig: '<rootDir>/tsconfig.test.json',
            diagnostics: true,
            stringifyContentPathRegex: '\\.html$',
            astTransformers: [require.resolve('jest-preset-angular/InlineHtmlStripStylesTransformer')],
        },
    }
};

Take a look at my comment here for the full explanation: https://github.com/thymikee/jest-preset-angular/issues/286#issuecomment-519050423

All 19 comments

This seems to be related to the tsconfig.

I was playing around trying not having a ./src and pointing the jest.config.js to another tsconfig.spec.json and started to get this error. Reverting my changes, it all worked again. I couldn't figure it out the real reason but if you want to take a look, this repo https://github.com/minuz/n4nd0-ng-playground.git has jest working with Angular libs and demo project.

Please post your jest config so we can help you find errors in your project configuration.

It seems like you are not applying astTransformers, if you override the globals part in your config, you have to set astTransformers manually, as it would be done in the preset.

Hi @wtho,

Here's my jest.config.js

module.exports = {
  globals: {
    'ts-jest': {
      tsConfig: '<rootDir>/tsconfig.spec.json'
    }
  },
  preset: 'jest-preset-angular',
  setupFilesAfterEnv: ['<rootDir>/setup.jest.ts'],
  testPathIgnorePatterns: [
    '/node_modules/',
    '/storybook-static/',
    'angularshots.test.js',
    'dist'
  ],
  modulePaths: ['<rootDir>/dist'],
  roots: ['<rootDir>/src', '<rootDir>/projects'],
  collectCoverage: true,
  coverageDirectory: 'coverage',
  coverageReporters: ['json', 'lcov', 'text', 'cobertura'],
  reporters: [
    'default',
    [
      './node_modules/jest-html-reporter',
      {
        pageTitle: 'Test Report',
        outputPath: './coverage/jest-report.html'
      }
    ],
    [
      'jest-junit',
      {
        suiteName: 'jest tests',
        output: './coverage/test_results.xml',
        classNameTemplate: '{classname}-{title}',
        titleTemplate: '{classname}-{title}',
        ancestorSeparator: ' › ',
        usePathForSuiteName: 'true'
      }
    ]
  ]
};

The interesting part is that if I remove the normal ./src from the default angular cli template and point the tsconfig.spec.json to another one, it gives this issue.

What's the default astTrasformers? Prior to this change, I haven't set it at all and it used to work.

Based on your suggestion, changed my globals to the following:

  globals: {
    'ts-jest': {
      tsConfig: '<rootDir>/tsconfig.spec.json',
      stringifyContentPathRegex: '\\.html$',
      astTransformers: [
        require.resolve('jest-preset-angular/InlineHtmlStripStylesTransformer')
      ]
    }
  },

This is the result

Fernandos-MacBook-Pro:n4nd0-ng-playground fernandobaba$ yarn test
yarn run v1.16.0
$ jest --config ./jest.config.js --json --outputFile=./coverage/jest-test-results.json
 FAIL  projects/n4nd0/tree-control/src/lib/treeview.component.spec.ts
  ● Test suite failed to run

    /Users/fernandobaba/Repositories/Personal/n4nd0-ng-playground/setup.jest.ts:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import 'jest-preset-angular';
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^

    SyntaxError: Unexpected string

      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:471:17)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:513:25)
          at Array.forEach (<anonymous>)

I pushed my changes to a branch called push-notifications...
https://github.com/minuz/n4nd0-ng-playground/tree/feature/push-notifications

Here is the jest.config that I used, the same error occurs when I mock a service that calls HTTP API from back-end, but the test was passed.
@wtho I did apply astTransformers in the first place and the error came out when I call HTTP api.
Please check my configuration.

module.exports = {
    clearMocks: true,

    coverageDirectory: "coverage",

    coveragePathIgnorePatterns: [
        "\\\\node_modules\\\\"
    ],
    coverageReporters: [
        "text-summary", "html",
    ],



    globals: {
        "ts-jest": {
            diagnostics: false,
            tsConfig: '<rootDir>/tsconfig.spec.json',
            stringifyContentPathRegex: '\\.html$',
            astTransformers: ["jest-preset-angular/InlineHtmlStripStylesTransformer"],
            allowSyntheticDefaultImports: true,
        },
        transform: {
            "^.+\\.(ts|html)$": "<rootDir>/node_modules/jest-preset-angular/preprocessor.js",
            "^.+\\.js$": "babel-jest"
        },

        moduleFileExtensions: ['ts', 'html', 'js', 'json'],
        transformIgnorePatterns: ['node_modules/(?!@ngrx)']
    },
    testEnvironment: 'jest-environment-jsdom-thirteen',
    moduleDirectories: [
      "node_modules",
      "src"
    ],

    moduleNameMapper: {
        '^@emp/root/(.*)$': '<rootDir>/src/app/$1',
        '^@emp/global/(.*)$': '<rootDir>/src/app/global/$1',
        '^@emp/core/(.*)$': '<rootDir>/src/app/core/$1',
        '^@emp/private/(.*)$': '<rootDir>/src/app/private/$1',
        '^@emp/public/(.*)$': '<rootDir>/src/app/public/$1',
        '^@emp/shared/(.*)$': '<rootDir>/src/app/shared/$1',
        '^@emp/assets/(.*)$': '<rootDir>/src/assets/$1',
        '^@emp/environments/(.*)$': '<rootDir>/src/environments/$1',
    },

    preset: "jest-preset-angular",

    reporters: [
        "default",
        [ "jest-junit", {
            suiteName: "jest Unit test report",
            outputDirectory: "./coverage/reports",
            outputName: "./junit.xml",
            classNameTemplate: "{classname}-{title}",
            titleTemplate: "{classname}-{title}",
            ancestorSeparator: " › ",
            usePathForSuiteName: "true",
            includeConsoleOutput: "true"
        }],
        [ "jest-html-reporters", {
            publicPath: "./coverage/reports",
            filename: "jest-report.html",
            expand: false
        }]
    ],


    roots: [
        "<rootDir>"
    ],
    setupFilesAfterEnv: ["<rootDir>/src/setupJest.ts"],
    snapshotSerializers: [
        "jest-preset-angular/AngularNoNgAttributesSnapshotSerializer.js",
        "jest-preset-angular/AngularSnapshotSerializer.js",
        "jest-preset-angular/HTMLCommentSerializer.js"
    ],
    testMatch: [
        "**/?(*.)+(spec).ts?(x)"
    ],

    transform: {
        "^.+\\.js$": "babel-jest"
    },
    transformIgnorePatterns: [
        "node_modules/(?!@ngrx|angular2-ui-switch|ng-dynamic)"
    ],
    verbose: false,


};

omg I couldn't be dumber... :p I didn't have ts-jest as devDependencies once added it and added the astTrasformers it all worked out :)

@minuz @wtho , I did add ts-jest and my test still get the error about jsdom. Can you guys take a look at my config I commented above?

@jackmercy your configuration is quite messed up and contains a lot of legacy configuration. Please refer to the current README.md and adjust your configuration accordingly.

The main culprit is transform, which points at babel-jest and simply does not allow jest to invoke ts-jest at all, but uses babel-jest instead.

@minuz at first glance your configuration looks good, there seems to be some issue with jest not transpiling setup.jest.ts. I remember this sometimes happened, when baseUrl was not set in tsconfig.spec.json, maybe try to play with this value or replace it with a js file (and require instead of import).

Happy coding!

@jackmercy , the way I fixed mine was taking a step back and creating a new setup.jest.ts based on the defaults specified on the documentation. Then adding item by item to check what was breaking.

In my case, I end up realising that jest-preset-angular sits on top of ts-jest and it's logic it's all around setting up ts-jest to work with Angular. If you check the source code, you can see what's the default preset is.

Then I started adding the preset values and it all worked out. You can check my repo setup. There's not much but it has libraries added with tests. Jest is configured to get code coverage and html reports to be used on CI/CD pipeline and the results are also used within Storybook.

Let me know if you need any clarification :)

@wtho btw, thanks for the awesome lib! It's quite handy!!

Hi @wtho ,
I did update my config according to the current README.md of jest-preset-angular as you suggest.
The problem did not happen when I run the first component, but then I run the 2nd component, I cause the jsdom error connect. Can you guy take a look at my config and test file, what when wrong? Sorry, I'm new to jest so there might be some dumb code I made.
Here is my config:

module.exports = {
    clearMocks: true,
    roots: [
        '<rootDir>'
    ],
    globals: {
        'ts-jest': {
            tsConfig: '<rootDir>/tsconfig.spec.json',
            stringifyContentPathRegex: '\\.html$',
            astTransformers: [
                require.resolve('jest-preset-angular/InlineHtmlStripStylesTransformer')
            ]
        }
    },
    moduleNameMapper: {
        '^@emp/root/(.*)$': '<rootDir>/src/app/$1',
        '^@emp/global/(.*)$': '<rootDir>/src/app/global/$1',
        '^@emp/core/(.*)$': '<rootDir>/src/app/core/$1',
        '^@emp/private/(.*)$': '<rootDir>/src/app/private/$1',
        '^@emp/public/(.*)$': '<rootDir>/src/app/public/$1',
        '^@emp/shared/(.*)$': '<rootDir>/src/app/shared/$1',
        '^@emp/assets/(.*)$': '<rootDir>/src/assets/$1',
        '^@emp/environments/(.*)$': '<rootDir>/src/environments/$1',
    },


    transform: {
        '^.+\\.(ts|js|html)$': 'ts-jest',
    },
    testEnvironment: 'jest-environment-jsdom-thirteen',
    moduleFileExtensions: ['ts', 'html', 'js', 'json'],
    transformIgnorePatterns: ['node_modules/(?!@ngrx)'],
    snapshotSerializers: [
        'jest-preset-angular/AngularSnapshotSerializer.js',
        'jest-preset-angular/HTMLCommentSerializer.js',
    ],
    preset: 'jest-preset-angular',
    setupFilesAfterEnv: ['<rootDir>/src/setupJest.ts'],
    testMatch: [
        '**/?(*.)+(spec).ts?(x)'
    ],
    reporters: [
        'default',
        [ 'jest-junit', {
            suiteName: 'jest Unit test report',
            outputDirectory: './coverage/reports',
            outputName: './junit.xml',
            classNameTemplate: '{classname}-{title}',
            titleTemplate: '{classname}-{title}',
            ancestorSeparator: ' › ',
            usePathForSuiteName: 'true',
            includeConsoleOutput: 'true'
        }],
        [ 'jest-html-reporters', {
            publicPath: './coverage/reports',
            filename: 'jest-report.html',
            expand: false
        }]
    ],
};

This is the test file that causes the error

import { async, ComponentFixture, TestBed, getTestBed } from '@angular/core/testing';
import { RegisterComponent } from './register.component';
import { ActivatedRoute, Router } from '@angular/router';
import { Injector, DebugElement } from '@angular/core';
import { AppModule } from '@emp/root/app.module';
import { APP_BASE_HREF } from '@angular/common';
import { PublicService } from '@emp/public/service/public.service';
import { SharedModule } from '@emp/root/shared/shared.module';
import { PublicModule } from '../../public.module';
import { By } from '@angular/platform-browser';
import { of } from 'rxjs';

jest.mock('@emp/public/service/public.service');

describe('RegisterComponent', () => {
    let component: RegisterComponent;
    let fixture: ComponentFixture<RegisterComponent>;
    let injector: Injector;
    let publicService: any;
    let route: any;
    let router: Router;
    let registerAPI: any;
    // const compilerConfig = {preserveWhitespaces: false} as any;

    beforeEach(async(() => {
        TestBed.configureTestingModule({
            imports: [
                AppModule,
                SharedModule,
                PublicModule,
            ],
            providers: [
                PublicService,
                { provide: APP_BASE_HREF, useValue: '/' }
            ]
        });
    }));

    beforeEach(() => {
        fixture = TestBed.createComponent(RegisterComponent);
        component = fixture.componentInstance;

        injector = getTestBed();

        // mock ActivatedRoute
        route = injector.get(ActivatedRoute);

        // router
        router = injector.get(Router);
        // public service

        publicService = injector.get(PublicService);
        registerAPI = jest.spyOn(publicService, 'register')
            .mockImplementation(() => of(null) );

        fixture.detectChanges();
    });

    describe('Should create Register component', () => {
        test('Component creation', () => {
            expect(component).toBeTruthy();
        });

        test('Register form snapshot', () => {
            expect(component.registerSucceed).toEqual(false);
            fixture.detectChanges();
            expect(fixture).toMatchSnapshot();
        });

        test('Register success snapshot & navigation to landing page', () => {
            component.registerSucceed = true;
            fixture.detectChanges();

            expect(fixture).toMatchSnapshot();

            spyOn(router, 'navigate');
            fixture.debugElement.query(By.css('.go-to-landing-page')).nativeElement.click();
            expect(router.navigate).toHaveBeenCalledWith(['/public/signin']);
        });
    });

    describe('Check existance', () => {
        test('Inputs form field properties', () => {
            expect(component.firstName).toBeDefined();
            expect(component.lastName).toBeDefined();
            expect(component.company).toBeDefined();
            expect(component.department).toBeDefined();
            expect(component.jobTitle).toBeDefined();
            expect(component.email).toBeDefined();
            expect(component.deskPhone).toBeDefined();
            expect(component.mobilePhone).toBeDefined();
        });

        test('Component properties', () => {
            expect(component.registerForm).toBeDefined();
            expect(component.registerSucceed).toBeDefined();
            expect(component.phonePattern).toBeDefined();
        });
    });

    describe('Static content', () => {
        let fixtureDebugElement;

        beforeAll(() => {
            fixtureDebugElement = fixture.debugElement;
        });

        test('Register form', () => {
            component.registerSucceed = false;
            fixture.detectChanges();
            // page header
            const pageTitleDebugElement = fixtureDebugElement.query(By.css('#register-page-title'));
            expect(pageTitleDebugElement.nativeElement.textContent.trim()).toBe('REGISTER NEW ACCOUNT');
            // register button
            const registerButton = fixtureDebugElement.query(By.css('#register-button')).nativeElement;
            expect(registerButton.textContent.trim()).toBe('REGISTER');
            // inputs label
            const firstName = fixtureDebugElement.query(By.css('#label-first-name'));
            expect(firstName.nativeElement.textContent.trim()).toBe('First name');

            const lastName = fixtureDebugElement.query(By.css('#label-last-name'));
            expect(lastName.nativeElement.textContent.trim()).toBe('Last name');

            const company = fixtureDebugElement.query(By.css('#label-company'));
            expect(company.nativeElement.textContent.trim()).toBe('Company');

            const department = fixtureDebugElement.query(By.css('#label-department'));
            expect(department.nativeElement.textContent.trim()).toBe('Department');

            const jobTitle = fixtureDebugElement.query(By.css('#label-job-title'));
            expect(jobTitle.nativeElement.textContent.trim()).toBe('Job title');

            const email = fixtureDebugElement.query(By.css('#label-email'));
            expect(email.nativeElement.textContent.trim()).toBe('Email address');

            const deskPhone = fixtureDebugElement.query(By.css('#desk-phone-number'));
            expect(deskPhone.nativeElement.textContent.trim()).toBe('Desk phone number');

            const mobilePhone = fixtureDebugElement.query(By.css('#mobile-phone-number'));
            expect(mobilePhone.nativeElement.textContent.trim()).toBe('Mobile number');
        });

        test('Register success message', () => {
            component.registerSucceed = true;
            fixture.detectChanges();
            // page header
            const pageTitleDebugElement = fixtureDebugElement.query(By.css('#register-page-title'));
            expect(pageTitleDebugElement.nativeElement.textContent.trim()).toBe('REGISTER NEW ACCOUNT');
            // success message
            const successMessages = fixture.debugElement.queryAll(By.css('.success-text'));
            expect(successMessages[0].nativeElement.textContent.trim()).toContain('Dear');
            expect(successMessages[1].nativeElement.textContent.trim())
                // tslint:disable-next-line:max-line-length
                .toContain('Your request was sent successfully. We will contact you soon after it was processed. Thank you for your registration!');
            expect(successMessages[2].nativeElement.textContent.trim()).toContain('Go to landing page');
        });
    });

    describe('Interact with Inputs', () => {
        test('First name input', () => {
            // empty input
            expect(component.firstName.errors['required']).toBeTruthy();
            expect(component.firstName.invalid).toBeTruthy();
            // correct data
            component.firstName.setValue('Van Cot');
            expect(component.firstName.errors).toBeNull();
            expect(component.firstName.invalid).toBeFalsy();
        });

        test('Last name input', () => {
            // empty input
            expect(component.lastName.errors['required']).toBeTruthy();
            expect(component.lastName.invalid).toBeTruthy();
            // correct data
            component.lastName.setValue('Giang');
            expect(component.lastName.errors).toBeNull();
            expect(component.lastName.invalid).toBeFalsy();
        });

        test('Company input', () => {
            // empty input
            expect(component.company.errors['required']).toBeTruthy();
            expect(component.company.invalid).toBeTruthy();
            // correct data
            component.company.setValue('Rosen Gr');
            expect(component.company.errors).toBeNull();
            expect(component.company.invalid).toBeFalsy();
        });

        test('Email address input', () => {
            // empty input
            expect(component.email.errors['required']).toBeTruthy();
            expect(component.email.invalid).toBeTruthy();
            // email validate
            component.email.setValue('test');
            expect(component.email.errors['email']).toBeTruthy();
            expect(component.email.invalid).toBeTruthy();
            // duplicate
            component.email.setValue('test@jest');
            component.email.setErrors({ duplicate: true });
            expect(component.email.invalid).toBeTruthy();
            // correct data
            component.email.setValue('[email protected]');
            expect(component.email.errors).toBeNull();
            expect(component.email.invalid).toBeFalsy();
        });

        test('Desk phone number input', () => {
            component.deskPhone.setValue('jest12121212');
            component.deskPhone.setErrors({ pattern: true });
            expect(component.deskPhone.invalid).toBeTruthy();
            // correct data
            component.deskPhone.setValue('012121212');
            expect(component.deskPhone.errors).toBeNull();
            expect(component.deskPhone.invalid).toBeFalsy();
        });

        test('Desk phone number input', () => {
            component.mobilePhone.setValue('jest12121212');
            component.mobilePhone.setErrors({ pattern: true });
            expect(component.mobilePhone.invalid).toBeTruthy();
            // correct data
            component.mobilePhone.setValue('012121212');
            expect(component.mobilePhone.errors).toBeNull();
            expect(component.mobilePhone.invalid).toBeFalsy();
        });
    });

    describe('Submit register form', () => {
        let registerButton: DebugElement;
        const createFormValue = (
            _firstName: string,
            _lastName: string,
            _company: string,
            _email: string,
            _department: string = '',
            _jobTitle: string = '',
            _deskPhone: string = '',
            _mobilePhone: string = ''
        ): void => {
            component.registerForm.setValue({
                firstName: _firstName,
                lastName: _lastName,
                company: _company,
                email: _email,
                department: _department,
                jobTitle: _jobTitle,
                deskPhone: _deskPhone,
                mobilePhone: _mobilePhone
            });
            fixture.detectChanges();
        };

        beforeEach(() => {
            registerButton = fixture.debugElement.query(By.css('#register-button'));
        });

        test('Correct submit data', async () => {
            expect(component.registerForm.valid).toBeFalsy();

            createFormValue('Joe', 'Badass', 'Rosen', '[email protected]', 'a', 'a', '11111', '11111');
            expect(component.registerForm.valid).toBeTruthy();

            expect(registerButton.nativeElement.textContent.trim()).toBe('REGISTER');

            expect(registerButton.nativeElement.disabled).toBeFalsy();
            registerButton.nativeElement.click();

            fixture.detectChanges();
            // await fixture.whenStable;

            expect(registerAPI).toHaveBeenCalled();
        });

        test('incorrect submit data', () => {
            createFormValue('', 'Badass', 'Rosen', 'joegmail.com');
            fixture.detectChanges();
            expect(component.registerForm.valid).toBeFalsy();

            expect(registerButton.nativeElement.textContent.trim()).toBe('REGISTER');
            expect(registerButton.nativeElement.disabled).toBeTruthy();
            registerButton.nativeElement.click();

            fixture.detectChanges();
            expect(registerAPI).not.toHaveBeenCalled();
        });
    });
});

Notice that all the test is passed but jsdom error connect still occurs.

I was able to fix the problem.
My config after refactors is working okay.
Apparently, the JSDOM error appears when an async test is running.
After removing all async test, my test is fine, no error is display.
I still wonder why the async test causes this error, or would I have to do when writing an async test.
How to let jest know that when the async test is finished and not cause the error.
@wtho

Your test suite looks quite big, please share a minimal example or a minimal reproduction, so I can have a quick look.

I quickly tried to add this test to the jest-preset-angular test code base and it worked flawlessly (it failed when comparing 'a' to 'b', but passed when comparing 'a' to 'a':

  it('should act properly in a promise-returning test', async () => {
    await new Promise(rs => setTimeout(rs, 1000))
    expect('a').toEqual('b');
  });

@wtho I think he might be referring to:

    beforeEach(async(() => {
        TestBed.configureTestingModule({
            imports: [
                AppModule,
                SharedModule,
                PublicModule,
            ],
            providers: [
                PublicService,
                { provide: APP_BASE_HREF, useValue: '/' }
            ]
        });
    }));

This is taken from the import:

import { async, ComponentFixture, TestBed, getTestBed } from '@angular/core/testing';

(the async variable)

I'm having the exact same issues as the dude.

This is what I'm using for my jest.config.js file:

console.log('loading jest.config.js file');
module.exports = {
    preset: 'jest-preset-angular',
    setupFilesAfterEnv: ['<rootDir>/tests/client/jest-setup.ts'],
    globals: {
        'ts-jest': {
            tsConfig: '<rootDir>/tsconfig.test.json',
            diagnostics: true,
            stringifyContentPathRegex: '\\.html$',
            astTransformers: [require.resolve('jest-preset-angular/InlineHtmlStripStylesTransformer')],
        },
    }
};

Take a look at my comment here for the full explanation: https://github.com/thymikee/jest-preset-angular/issues/286#issuecomment-519050423

As the ECONNREFUSED issue is resolved, I will close this issue for now.

If the async issue still persists, you can create another issue, but please supply a minimal example of the problematic test suite.

@wtho I have been receiving this error myself but I think it is environment based. I recently ported over my company's CI from Jenkins to Github Actions. While the tests passed fined this error does pop up. I've been trying to figure it out but to no avail.

● Console

console.error node_modules/jest-environment-jsdom-sixteen/node_modules/jsdom/lib/jsdom/virtual-console.js:29
  Error: Error: connect ECONNREFUSED 127.0.0.1:80
      at Object.dispatchError (/home/runner/work/web/web/node_modules/jest-environment-jsdom-sixteen/node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:62:19)
      at Request.<anonymous> (/home/runner/work/web/web/node_modules/jest-environment-jsdom-sixteen/node_modules/jsdom/lib/jsdom/living/xhr/XMLHttpRequest-impl.js:654:18)
      at Request.emit (events.js:327:22)
      at Request.onRequestError (/home/runner/work/web/web/node_modules/request/request.js:877:8)
      at ClientRequest.emit (events.js:315:20)
      at Socket.socketErrorListener (_http_client.js:426:9)
      at Socket.emit (events.js:315:20)
      at emitErrorNT (internal/streams/destroy.js:92:8)
      at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)

Hey @jarretmoses,
without access to more files I cannot help you, but this error might have occurred due to:

  • HTML was not inlined by the AST transformers and therefore the Angular JIT-Compiler requests 127.0.0.1:80 for the templateUrl path or
  • something with @angular/core/testing's async

If you used async, please try to recreate a minimal example in a new jest-angular project and create a new issue so we can fix it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ArielGueta picture ArielGueta  ·  4Comments

bgoscinski picture bgoscinski  ·  3Comments

gagle picture gagle  ·  5Comments

jesusbotella picture jesusbotella  ·  8Comments

Hotell picture Hotell  ·  3Comments