How to install mocha, chai?

Hi
my name is frank I would like to learn to use mocha, chai, to test jquery/javasript programparts, but I need help to install it. I have windows 7, I learned from my research , I need node.js but I don’t know what to do. as I type npm… I get the error npm is not recogmized, I made mistake, obviously, at the moment I have no idea hot to get farther, please help me, thank you, frank
ps: I installed node.js, and running npm -v, I’ve got the error msg: referenceerror: npm is not defined. this is what I used:
https://codeburst.io/javascript-unit-testing-using-mocha-and-chai-1d97d9f18e71

Your question is a bit weird, but in Meteor app you need to add meteor before your npm command.

For example:
meteor npm i

1 Like

Hi
I am sorry for inconveniences but I am very beginer, at the moment even struggling to instal and be able to run mocha. I downloaded node.js and installed it. as I clicked on it, I got a command prompt, where I typed te npm… command, where I got the above mentioned error message. I don’t understand the whole thing, please help me, thank you, frank

Hi storyteller
I don’t understand it. I downloaded node.js from the official site, installed it, and clicking on it, I’ve got cli, wher I typed npm and it was not recognized. what did I do wrong? this testing matter with mocha is difficult, not having proper documentation or relevant support is not possible to learn and use it. still I don’t get it. is there any help? thank you frank

Are you trying to use mocha with a Meteor app, or is this for a standalone Node app?

to be honest I am very confused. I downloaded node.js and installed it. clicking on it a cli opened up and tried to follow instructions from node.js site, I’ve got error message.
another option was: sitepoint: I copied and pasted links in my html page, then initializing mocha , not working. I try to test jquery code of form fields and I screwed up. can I get help? thank you , frank
ps : if I use meteor , what shoul I do to be able to use mocha? thank you, frank

I tried standalone node app

If I remember correctly you will have to install npm for that before you can proceed. Can’t really help you there as I haven’t build a node only app in ages so I don’t recall what the process there is.

Hi
thank you for help. I have a different problem. I have an experiment where I try to make ‘div’ with an image inside flexible using $(window).resize(function()){} using .width() and .height() but I don’t know why the img is not responsive, not following the div.

	  $(".city01").ready(function(){
		
        var h2 = $(".city01").width();
				
		$(".city01").width(h2);
		$(".city01").height(h2);
		
		$(".imgsz").width(h2);
		$(".imgsz").height(h2);
	<!--	$(".city01").text($("#div11").width());-->
		//$(".city01").height();
		/*
		if ($(".imgsz").width() < $(".imgsz").height()) {
			$(".imgsz").height(h2);
		} else {
			$(".imgsz").width(h2);
		(*/
		 $(window).resize(function(){
		 
			
			h2 = $(".city01").width();
			
			//$(".city01").css({'height':(h11)+'px'});
			$("#div11").text("   width : "+ $(".city01").width ()+ "  height : "+ $(".city01").height());
		/*	
		if ($(".imgsz").width() < $(".imgsz").height()) {
			$(".imgsz").height(h11);
		} else {
			$(".imgsz").width(h11);
		}
        */
		$(".city01").width(h2);
		$(".city01").height(h2);
		
		$(".imgsz").width(h2);
		$(".imgsz").height(h2);
		});
	
	 });