I faced with a problem while writing a test for my react component.
There is my test
And there is my console message
I also tried npm/yarn install, and also looked at similar problems on the Internet but ... nothing. Maybe someone faced with a similar problem
Jest file
Related
Im working on a node command line application which requires jest testing. Ive installed it as a dependency in my package.json, and when I try to run the 'npm run test' command, it gives me a bunch of errors. Anyone know what's going on? Im very new to node and web dev in general, so any feedback would be much appreciated!
I am fairly new to React and am trying to run an example to get started with understanding how Twilio interfaces with React/Node. I am currently using the repo https://github.com/twilio/twilio-video.js, and am trying to run the test > framework > twilio-video-react, but when I npm install then npm start, the server starts, but throws the error:
Failed to compile
./src/App.js
Module not found: Can't resolve 'twilio-video'
I did `npm install twilio-video`, but still throwing error. What am I missing here? Can anyone else get this example started? I want a base example with Twilio Video working with React so I can learn from there, any other resources would help, thanks!
I tried these two examples as well, but they are outdated:
https://www.twilio.com/blog/2018/03/video-chat-react.html
https://www.twilio.com/blog/2016/03/building-a-react-powered-video-chat.html
Okay, got an example up and running with a little fudging.
I followed this example: https://www.twilio.com/blog/2018/03/video-chat-react.html
But there were a few old libraries that were causing errors.
Posted a working version on my Github linked here.
I have tried the related solutions for this problem (eg. add the dependencies through 'package.json' and run npm install) but unfortunately they didn't solve it. Problem is when I run the code from the accepted answer from the following discussion:
Node.js, Ajax sending and receiving Json
everything works fine. the Ajax-call works and I get the result with the data. But in the console I get the error.
'ReferenceError: Can't find variable: require' (Globale code — requesthandle.js:2ReferenceError: Can't find variable: require)
Any ideas which could be the problem here? Thank you!
This is the code I am using:
requesthandle.js (server side, by executing node requesthandle.js) ==>
http://i67.tinypic.com/24zbyma.png
and
list.html (by visiting mydomain/list.html)
http://i65.tinypic.com/mwp3md.png
Found the solution.. overlooked the fact I included the requesthandle.js in my list.html / client-side code. Thank you for your help Arpit Solanki! Seems your first remark included the solution: I was using it frontend by mistake..
I am configuring my Angular 4 app to build using AoT for production, as described in this post and GitHub repository.
There have been lots of errors in this process, mainly pertaining to #types which I have resolved, but there is one curious error that remains when running npm run build:prod:
ERROR in Could not resolve "./app/src/app.module.ts" from "./app/src/app.module.ts".
I have no idea how to solve this, and Googling yields meager results. Can anyone help me out with what this might mean and how to solve it?
I don't know if it's a tsconfig.json error or otherwise. Can anyone help?
So, armed with this tutorial, I decided to add some unit testing to my node.js app. My gruntfile seems to be OK, and when I type grunt nodeunit my only test runs just fine, but after that, it crashes with error Fatal error: Cannot find module 'tap':
$> grunt nodeunit
Running "nodeunit:all" (nodeunit) task
Testing db.test.js
.OK
Fatal error: Cannot find module 'tap'
I didn't know anything about this module, but after googliing it up, it seemed that it's something nodeunit would require. And indeed, there it is: $MY_NODE_APP/node_modules/nodeunit/node_modules/tap exists, and when I launch node in $MY_NODE_APP/node_modules/nodeunit and type require('tap') in interactive console, I get some object with a lot of stuff that gives me an impression that it works as it should.
So, the obvious question: why do I get this error, and how can I fix it?
Gruntfile:
module.exports = function(grunt) {
grunt.initConfig({
nodeunit: {
all: ['./**/*.test.js']
}
});
grunt.loadNpmTasks('grunt-contrib-nodeunit');
};
Update: Installed tap to my project, but it didn't help too.
I landed on this question and have since resolved my own issue. I'll post my resolution as it might be helpful to someone else:
First the similarities:
I was just getting my Gulp scripts setup, and I got this error when running my tests:
Fatal error: Cannot find module 'tap'
Which didn't make sense because I wasn't using that library!
How I resolved:
Turns out my paths were all kind of screwed up in my gulpfile.js. Therefore I was trying to unit test all of the modules in my node_modules folder!
Here's the new path:
paths: {
mocha: [
'**/*.test.js',
'!node_modules/**/*.js'
]
}
The issue for me was that I was inadvertently running the tests within the node_modules directory. My npm test was mocha **/*.test.js and when I changed it to mocha src/**/*.test.js all of a sudden the message went away. Makes sense really.
I have solved the problem by adding another '*' right after "mocha" it is related to the folder's path so it may also fix the problem in other cases.
I solved the issue (well, this issue — it wasn't the last one) by installing the tap module manually.