Hello im trying to find to build a application on my pipeline using integrations tests with Jest version 27.5.1 as well as jest-cli 27.5.1 all the tests work on my localhost however when my code runs through the Pipeline it shows the following Error
FetchError: request to http://localhost/callback?usid= failed, reason: connect ECONNREFUSED 127.0.0.1:80
and if i add a skip to this test the next test breaks as well
I've tried reading the documentation of jest to see if the root of the problem could be syntax i changed the Url where im doing the request for the API and also cleared added on the function afterEach() server.resetHandlers() as well as LocalStorage.clear() to clear up anything that might be considered Old data
I created a react project using create-react-app however when ran yarn test to see if the initial tests pass I get
TypeError: Network request failed
at XMLHttpRequest.xhr.onerror (/home/ubuntu/wonderland/hackernews/node_modules/whatwg-fetch/fetch.js:436:16)
at XMLHttpRequest.callback.(anonymous function) (/home/ubuntu/wonderland/hackernews/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:289:32)
at invokeEventListeners (/home/ubuntu/wonderland/hackernews/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:219:27)
at invokeInlineListeners (/home/ubuntu/wonderland/hackernews/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:166:7)
at EventTargetImpl._dispatch (/home/ubuntu/wonderland/hackernews/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:122:7)
at EventTargetImpl.dispatchEvent (/home/ubuntu/wonderland/hackernews/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:87:17)
at XMLHttpRequest.dispatchEvent (/home/ubuntu/wonderland/hackernews/node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:61:35)
at XMLHttpRequest.abort (/home/ubuntu/wonderland/hackernews/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:405:16)
at Object.abort (/home/ubuntu/wonderland/hackernews/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:315:13)
at RequestManager.close (/home/ubuntu/wonderland/hackernews/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:146:21)
at Window.close (/home/ubuntu/wonderland/hackernews/node_modules/jsdom/lib/jsdom/browser/Window.js:362:29)
at JSDOMEnvironment.dispose (/home/ubuntu/wonderland/hackernews/node_modules/jest-environment-jsdom/build/index.js:44:19)
at Promise.resolve.then (/home/ubuntu/wonderland/hackernews/node_modules/jest-cli/build/runTest.js:102:17)
I'm working in Cloud9 editor using ssh connected to my dev server (Ubuntu) hosted in AWS. Tests are working fine in my local machine (Ubuntu).
Thanks for the help!
I already solve my problem. I'm following a book entitled "The Road to Learn React" and I think that the one causing my error is the part where I fetch data from an external API. The book forgot to include an import for fetch which is this one:
import fetch from 'isomorphic-fetch'
Then, it solves my problem like a charm.
I am an AMQP/RabbitMQ newbie, and relative Node.js newbie. Can I use the amqplib NPM library client-side?
I'd like to be able to push messages direct to RabbitMQ from my Angular app. I have used Browserify to modularise a lot of my client-side code. I am now starting to experiment with RabbitMQ and would like to push messages direct from the browser to cloud-based queues over the amqp protocol.
I have installed amqplib via NPM and written/pasted the following module:
var amqp = require('amqplib/callback_api');
var push = function(){
console.log('This is the CORE queue.pusher push function being triggered');
var connString = 'amqp://username:pwd#blabla.rmq.cloudamqp.com/username';
amqp.connect(connString, function(err, conn) {
if (err){
console.log("core queue.pusher push error %s", err);
}else {
conn.createChannel(function (err, ch) {
var q = 'FatController';
var msg = 'Hello World!';
ch.assertQueue(q, {durable: false});
// Note: on Node 6 Buffer.from(msg) should be used
ch.sendToQueue(q, new Buffer(msg));
console.log(" [x] Sent %s", msg);
});
setTimeout(function () {
conn.close();
process.exit(0)
}, 500);
}
});
};
module.exports = {push:push};
When I try running this I get the following error:
bundle.js:32074 TypeError: QS.unescape is not a function
at openFrames (bundle.js:9551)
at connect (bundle.js:9629)
at Object.connect (bundle.js:7959)
at Object.push (bundle.js:7652)
at controller.pushQueueEntry (bundle.js:7805)
at fn (eval at compile (bundle.js:32907), <anonymous>:4:184)
at callback (bundle.js:44543)
at Scope.$eval (bundle.js:35710)
at Scope.$apply (bundle.js:35810)
at HTMLInputElement.<anonymous> (bundle.js:44548)
at defaultHandlerWrapper (bundle.js:21283)
at HTMLInputElement.eventHandler (bundle.js:21271)
Am I barking up the wrong tree here? Will amqplib only run in a 'proper' node environment?
As a secondary question, what is the best way to determine whether a particular NPM package will run in the browser environment? It seems to me that some NPM packages will run in the browser, and some won't - what is the best way to be confident about this?
Will amqplib only run in a 'proper' node environment?
Yes, I'm afraid so.
As a secondary question, what is the best way to determine whether a particular NPM package will run in the browser environment? It seems to me that some NPM packages will run in the browser, and some won't - what is the best way to be confident about this?
It's not always clear if a package can run in a browser or not, so you have to apply some heuristics:
Does a package require setting up "plain" TCP connections (meaning connections that aren't used for the usual web-based protocols like HTTP(S) or WebSockets)? If so, it's probably a server-side package.
Does a package require reading arbitrary files? If so, again, probably server-side.
Does a package provide, or depend on, native Node.js addons? If so, it's a server-side package.
As an extension of these: does it use fs, net, cluster, http, https, tls, dns, os, tty or dgram? Most likely server-side.
Packages that can be used client-side typically say so in their documentation, so if it isn't specifically mentioned, there's a good chance that it's only server-side.
I hadn't used Browserify in a while, so I had to check, but it looks like it doesn't warn you if the code you pass it depends on server-side modules. It will create a bundle that at some point will just fail with an error, much like what you're running in to.
Webpack, another commonly used bundler, has a concept of deployment targets. By default, it will target browsers, and when you try to bundle a project that depends on server-side modules like the ones I mentioned above, you will get an error:
$ webpack -p bundle.js
Hash: 767ace79fc17abef93e8
Version: webpack 2.6.1
Time: 3983ms
Asset Size Chunks Chunk Names
bundle.js 308 kB 0 [emitted] [big] main
[0] <SNIP>
ERROR in ./~/amqplib/lib/connect.js
Module not found: Error: Can't resolve 'net' in '/private/tmp/node_modules/amqplib/lib'
# ./~/amqplib/lib/connect.js 152:11-25
# ./~/amqplib/channel_api.js
# ./test.js
ERROR in ./~/amqplib/lib/connect.js
Module not found: Error: Can't resolve 'tls' in '/private/tmp/node_modules/amqplib/lib'
# ./~/amqplib/lib/connect.js 155:11-25
# ./~/amqplib/channel_api.js
# ./test.js
As you can see, my test file uses amqplib, which depends on net and tls, which are both not available in the browser environment. So if you're unsure about whether or not a package can be used in a browser, Webpack provides you with a safety net.
I've been working with my repo for a while, it's a clone of the angular2-seed repo. It includes webpack 2 (I think it's still beta) and async routes.
I did some tests and reverted to a previous state, but after installing packages with npm it fails loading async components with the following message in the browser:
browser_adapter.js:85 EXCEPTION: Error: Uncaught (in promise): Error: Cannot find module './+tickets'.
The plus sign is not a typo, the folder is actually called "+tickets" and it contains an index.ts file. It always worked, and now for some reason it doesn't.
I tried everything, but the error is so clueless that I don't know where to watch. Maybe the webpack-dev-server is not serving the files correctly..?
An alternative plan would be to start everything from scratch and then move the modules, but I'm really interested to where the problem is for future implementations.
Thanks a lot for the help
Hi I've created Angular2 lazy loading demo using RC 6.
Please checkout https://github.com/Quramy/ng2-lazy-load-demo .
I have been trying to get the following angular twitter API app to work out of the box but am running into an error on startup.
I am running node v0.10.36, npm 1.4.28
I just wanted to throw it out to the wider community to see if anyone could help me out.
I am trying to get the app working and am running into the error below. I tried a couple of things eg changing port, changing package.json to reflect a newer version of npm but I just don't seem to be able to get it to work. Any assistance would be appreciated. Thanks in advance.
It looks like all the node modules installed correctly.
/Users/billyjlennon/sample-angular-node/routes/tweets.js:36
var i = 0, len = tweets.length;
^
TypeError: Cannot read property 'length' of undefined
at /Users/billyjlennon/sample-angular-node/routes/tweets.js:36:28
at responseHandler (/Users/billyjlennon/sample-angular-node/node_modules/twit/lib/oarequest.js:362:14)
at passBackControl (/Users/billyjlennon/sample-angular-node/node_modules/twit/node_modules/oauth/lib/oauth.js:374:13)
at IncomingMessage.<anonymous> (/Users/billyjlennon/sample-angular-node/node_modules/twit/node_modules/oauth/lib/oauth.js:386:9)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickCallback (node.js:442:13)
It would be such a handy app if I could get it to work!!!
Have you done this per the readme:
Create a config.js file using config.sample.js as a template. Fill in your Twitter App API Keys. You will need to create a Twitter application.
The fact that length is undefined indicates you aren't getting any data back.