question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Doesn't work with jest

See original GitHub issue

I keep hitting these errors when rendering a component

console.error ../../node_modules/jsdom/lib/jsdom/virtual-console.js:29
    Error: Error: connect ECONNREFUSED 127.0.0.1:80
        at Object.dispatchError (/home/marcus-sa/Git/siteattention/dashboard/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:54:19)
        at Request.<anonymous> (/home/marcus-sa/Git/siteattention/dashboard/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:675:20)
        at Request.emit (events.js:214:15)
        at Request.onRequestError (/home/marcus-sa/Git/siteattention/dashboard/node_modules/request/request.js:881:8)
        at ClientRequest.emit (events.js:209:13)
        at Socket.socketErrorListener (_http_client.js:406:9)
        at Socket.emit (events.js:209:13)
        at emitErrorNT (internal/streams/destroy.js:91:8)
        at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
        at processTicksAndRejections (internal/process/task_queues.js:77:11) undefined


Error: Failed: "Failed to load users.component.html"
Error: 
    at Env.it (/home/marcus-sa/Git/siteattention/dashboard/node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:91:24)
    at it (/home/marcus-sa/Git/siteattention/dashboard/node_modules/jest-jasmine2/build/jasmine/jasmineLight.js:93:21)
    at env.<computed> (/home/marcus-sa/Git/siteattention/dashboard/node_modules/jest-preset-angular/zone-patch/index.js:84:27)
    at /home/marcus-sa/Git/siteattention/dashboard/libs/users/src/lib/users.component.spec.ts:30:3
    at ZoneDelegate.invoke (/home/marcus-sa/Git/siteattention/dashboard/node_modules/zone.js/dist/zone.js:396:30)
    at Zone.run (/home/marcus-sa/Git/siteattention/dashboard/node_modules/zone.js/dist/zone.js:153:47)
    at Suite.<anonymous> (/home/marcus-sa/Git/siteattention/dashboard/node_modules/jest-preset-angular/zone-patch/index.js:40:21)
    at addSpecsToSuite (/home/marcus-sa/Git/siteattention/dashboard/node_modules/jest-jasmine2/build/jasmine/Env.js:496:51)
    at Env.describe (/home/marcus-sa/Git/siteattention/dashboard/node_modules/jest-jasmine2/build/jasmine/Env.js:466:11)
    at describe (/home/marcus-sa/Git/siteattention/dashboard/node_modules/jest-jasmine2/build/jasmine/jasmineLight.js:81:18)

I’ve seen multiple issues where people wanted Jest support and it was added… But from what it looks like it doesn’t work? jest-preset-angular inlines all the HTML, so there’s really no reason for it to be doing a http request to get the template.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ike18tcommented, Aug 22, 2019

In the 2 diff apps that I’m using jest with angular I use this builder for the tests:

https://www.npmjs.com/package/@angular-builders/jest

You didn’t mention whether you are using this already or not but I hope this helps.

On Wed, Aug 21, 2019 at 9:37 PM Brandon Domingue notifications@github.com wrote:

Shallow render is mostly a wrapper around TestBed. The Http request is made to fetch the HTML template during the TestBed.compileComponents call. I believe it only makes an http request when the template is in a separate file than the component class. Could you try writing an equivalent test with TestBed for the same component? My guess is that the TestBed test would fail in the same manner when you called compile components.

Sorry for the lack of formatting, I’m on a phone at the moment.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/getsaf/shallow-render/issues/129?email_source=notifications&email_token=AABIWLMOTZYYXG6ITWWD6PLQFXUT5A5CNFSM4IOINJAKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD43TEAI#issuecomment-523710977, or mute the thread https://github.com/notifications/unsubscribe-auth/AABIWLPUHSKWKEV7W62MY63QFXUT5ANCNFSM4IOINJAA .

0reactions
marcus-sacommented, Sep 20, 2019

@getsaf actually it was a problem with me not including html as a transform matcher for ts-jest

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting - Jest
Use this guide to resolve issues with Jest. Tests are Failing and You Don't Know Why​. Try using the debugging support built into...
Read more >
npm test/ jest not working - Stack Overflow
When I do npm test /jest, I am getting the following error: > @ test /Users/suparnasoman/Downloads/create-react-app-master > node packages/react ...
Read more >
Troubleshooting · Jest
Use this guide to resolve issues with Jest. Tests are Failing and You Don't Know Why #. Try using the debugging support built...
Read more >
watch doesn't work · Issue #775 · facebook/jest - GitHub
If I run jest --watch in my project, it runs the tests once: Using Jest CLI v0.9.0, jasmine2, babel-jest PASS ...
Read more >
Successfully Throwing Async Errors with the Jest Testing Library
The first thing I tried, which didn't work, was to mock error results from the functions passed into the validateUploadedFile() function. Makes ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found