Running Expresso TDD in Node.js on Windows - windows

Has anyone been able to get this to work?
Environment:
Windows 7 64-bit
node.js v0.6.7
npm 1.1.0-beta-10
expresso 0.9.2
I've successfully installed via npm from zip download (after modifying package.json to remove node-jscoverage dependence). 'npm ls' lists expresso as installed. After overcoming the problem described here by commenting out the reference to SIGINT, expresso will execute from cmd window. However, when I actually attempt to run test suites, I get a 'Cannot find module' error when it tries to open the first test suite. Any help would be appreciated.

You'll have to install the module locally, too.

Have you considered using mocha? It's supposed to be expresso's successor, written by the same author.

Related

Do NPM packages have to be installed globally to access their functionality via the command line?

I am having trouble understanding how the -g flag works in NPM. Specifically I'm struggling to understand how it relates to command-line functionality exposed by NPM modules.
I assumed that the difference between installing a package locally and globally was simply that a local package would not be available outside of the particular project. And of course that a globally installed package would be available in any project. I'm from a Rails background so this for me would be similar to installing a gem into a particular RVM versus installing it into the global RVM. It would simply affect which places it was available.
However there seems to be more significance than just scope in NPM. For packages that have command-line functionality, like wait-on, the package (as far as I can tell) is not available on the command line unless it's installed globally.
Local install doesn't make the command-line functionality available:
$ npm install wait-on
$ wait-on
=> -bash: /usr/local/bin/wait-on: No such file or directory
Global install does expose the command-line functionality
$ npm install wait-on -g
$ wait-on
=> Usage: wait-on {OPTIONS} resource [...resource]
Description:
wait-on is a command line utility which will wait for files, ports,
sockets, and http(s) resources to become available (or not available
using reverse flag). Exits with success code (0) when all resources
are ready. Non-zero exit code if interrupted or timed out.
Options may also be specified in a config file (js or json). For
example --config configFile.js would result in configFile.js being
required and the resulting object will be merged with any
Can you expose the command-line functionality using a local install?
Is it possible to install locally but also get the command line functionality? This would be very helpful for my CI setup as it's far easier to cache local modules than global modules so where possible I'd prefer to install locally.
If you are using npm 5.2.0 or later, the npx command is included by default. It will allow you to run from the local node modules: npx wait-on
For reference: https://www.npmjs.com/package/npx
I think you can access locally installed modules from the command line only if you add them to your "scripts" section of your package.json. So to use the locally installed version of wait-on, you can add an entry in "scripts" section of package.json like so "wait-on": "wait-on". Then to run it, you would have to do npm run wait-on. You can also do "wo": "wait-on" and then do npm run wo basically meaning what comes after the run is the script entry. In node_modules, there is a .bin folder and inside of this folder is all the executables that you can access this way.
Installing locally makes the package available to the current project (where it stores all of the node modules in node_modules). This is usually only good for using a module like so var module = require('module'); or importing a module.
It will not be available as a command that the shell can resolve until you install it globally npm install -g module where npm will install it in a place where your path variable will resolve this command.
You can find a pretty decent explanation here.
It is also useful to put commands in the scripts block in package.json as it automatically resolve local commands. That means you could have a script that depended on a package without having an undocumented dependency on the same.
If you need to run it locally on cmd, you have to go inside the node_modules and run from the path.

Why does running npm test result in: '.' is not recognized as an internal or external command, operable program or batch file.?

I have the following installed:
Windows 10
Git bash (mingw64)
Node.js v8.7.0
npm version 5.4.2
Packages:
chai 4.4.1
mocha 3.5.0
I have a sample mocha test that will always pass when it actually runs.
The command I'm running in my shell:
npm test
Output:
./node_modules/mocha/bin/_mocha
'.' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! Test failed. See above for more details.
For some reason I'm able to run this command directly:
./node_modules/mocha/bin/_mocha
Which results in
Sample Test
√ passes!
1 passing (4ms)
I'm guessing this has something to do with the weirdness of using a bash-like shell inside of windows, however I'm not sure how I can troubleshoot this from here.
Why might this error be happening, and is there a way to get 'npm test' to work properly without having to ditch using this windows programming environment?
Thanks & Regards
This may not be a perfect answer, but it fixes the issue in a way that is sufficient to continue developing:
in my package.json file I had:
"test" : "./node_modules/mocha/bin/_mocha"
Changing this to:
"test" : "node ./node_modules/mocha/bin/_mocha"
Made it so I could run npm test command fine.
I'm still unsure as to why the original value would not work since running that as a command in the shell works just fine.
If anyone sees this and wants to offer some insight that would be greatly appreciated.

Has anyone managed to add custom icons into Ionic in Windows?

I refer the instructions here
What I did (on Windows):
Install fontforge through web instead of 'brew'
Install SASS through Ruby GEM
Place my-icon.svg inside src/ (of the ionicons-master)
Run the python ./builder/generate.py
I think I am very closed. Until i saw this error message:
windowsError: The system cannot find the file specified
And I think I get even closer when I saw the last post of this link
But, I don't get what it means. I downloaded the .exe but it doesn't work.
Is it the python build only meant for MAC? Has anyone managed to make this work in Windows?

Integrate Jekyll to run into WebStorm on Windows

Is it possible to run Jekyll as External Tool into WebStorm? (same for RubyMine, IntelliJ IDEA, ...)
The most obvious thing is to run the jekyll.bat file:
...but this doesn't work.
I haven't found any solution so after some trial+error I discover this working configuration:
In this example I am using: RubyInstaller + gem install jekyll.
If you prefer using straight Ruby+DevKit then Program and Parameters paths must be changed according.

Installing CasperJS on Windows: How to do it correctly?

I know there is a documentation from CasperJS website about how to install CasperJS on Windows, but bear with me these guys only explained for the pros only.
If you are new to all this CasperJS and PhantomJS world, you dont stand a chance to understand not even spending two days trying to search the net for a better explanation.
I am working on a project that requires a screenshot of each website listed on my project website, looking around i found out that PhantomJS would be great for this task (website screenshot).
I downloaded PhantomJS and and pasted its phantomjs.exe file in system32 which is working well when i use cmd.exe to send command.
I even managed to grab screenshot with the phantomjs.exe only. but my problem came when i noticed the the workload could be easier when these two work together (CasperJS and PhantomJS) as i can even be able to reduce the size of the screenshot when using CasperJS.
In fact the only use that i want CasperJS for is the limiting of the shot size but since yesterday i have been trying to figure out how to make CasperJS work on Windows but with no avail.
I have downloaded CasperJS and tried to install it in many ways also trying to follow the documentation but nothing.
I changed the CasperJS folder name from its download name to CasperJS as the documantation suggest but when i check in the cmd trying to call some commands, nothing happens.
Anyway to cut the story shot can anyone help me in simple terms considering that i am a newbie to explain how CasperJS can be installed on window or if possible with PhantomJS only how can i re-size the iamge the the program produces lets say if i want a 960 to 400px.
Poor documentation for windows. http://casperjs.org/installation.html#windows
It starts off assuming you have already installed without telling you how to install.
So here it is if anyone else is confused about this. There is no actual install. It's just extracting zip contents to the right place.
download phantomjs for windows from the phantomjs site (it's a zip with binary inside)
extract the contents to C:\phantomjs
download the casperjs zip file from the casperjs website
extract the contents to C:\casperjs
Now you can add the following to the end your system or user PATH variable
;C:\phantomjs;C:\casperjs\batchbin
restart cmd.exe to pick up the new path variable or logout/login if you are running Console2 or Conemu terminal emulator (they won't pick up new paths by a simple close and re-open)
Now in the docs it says to run it like this
casperjs.bat myscript.js
Actually since both phantomjs.exe and casperjs.bat are now in the system PATH you can leave off the extension like this.
casperjs myscript.js
And when running phantomjs.exe just run
phantomjs
One more thing. It really doesn't matter where you install as long as you add that path to the system PATH. I installed to C:\usr\phantomjs and C:\usr\casperjs.
I itemize below the method that has served my needs on both my personal Windows and Ubuntu work PC. DO note that my method doesn't fiddle with PATH settings but involves a command you could save somewhere & copy and paste as needed:
Step 1: Gather the prerequisites
Download the casperjs and phantomjs versions you want to use
Make a directory to contain the things I want to list
Extract the downloaded phantomjs & copy its executable into the directory of step b
Extract casperjs and rename its folder to casperjs
Copy the renamed casperjs folder to the directory of step b
Create and save a file config.json to the directory of step b
config.json should contain phantomjs configurations as found here: http://phantomjs.org/api/command-line.html
Step 2: Running your script
Whenever you want to work with a file, follow the Step 1 details above
The next step assumes that you are in the directory created in step
b of Step 1 also have a file named first.js
On Windows: phantomjs.exe --config=config.json casperjs/bin/bootstrap.js --casper-path=casperjs --cli first.js
On Ubuntu: ./phantomjs --config=config.json casperjs/bin/bootstrap.js --casper-path=casperjs --cli first.js
Experimental config.js and first.js are listed below:
config.json
{"sslProtocol": "any", "cookiesFile": "biscuit", "maxDiskCacheSize": 1000, "diskCache": true}
first.js
var casper = require('casper').create({
pageSettings: {
loadImages: false,
loadPlugins: true,
userAgent: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6'
}
});
var url = "http://casperjs.org/";
casper.start(url).wait(60 * 1000 * 1, function() {
casper.echo('1 min has passed');
casper.capture('casperjs.png');
casper.exit();
});
casper.run();
Addendum: download and save the details of screenshots.js and run it as
phantomjs.exe --config=config.json casperjs/bin/bootstrap.js --casper-path=casperjs --cli screenshots.js http://phantomjs.org
Run Tests: download & save the details of picturefill-test.js and run it as
phantomjs.exe --config=config.json casperjs/bin/bootstrap.js
--casper-path=casperjs test --cli picturefill-test.js
As of CasperJS 1.1.0-DEV Beta 3 you should use this PATH: C:\casperjs\batchbin even though the documentation found here states you need to use C:\casperjs\bin
The reason to this is because C:\casperjs\batchbin includes a .BAT which C:\casperjs\bin does not include anything except some.js files.
after a 3days work, i managed to get it work the problem was with the path and the installation of phantom. i had made the path to a folder but the installation was pointing to the exe file all i had to do was to put the exe file into a folder phantomjs and that was it thank for your help all.
Many of the other answers are out of date. Since it seems like the correct install process keeps changing all the time, I suspect my answer will be out of date also in a few days, but as of March 19, 2015, this is the answer. The other answers, even highly upvoted ones, do not work, so don't waste your time. Good luck. Casperjs seems quite good.
If you download PhantomJS 2.0 and casperjs 1.1-beta3 zip file and put the batchbin directory in the path and put phantom exe in that same folder, then run casperjs, on Windows 8.1 I get the error "CasperJS needs PhantomJS v1.x".
So, I got the latest casperjs direct from github, which has no batchbin directory, so I put just the C:\casperjs\bin directory in the path instead and this worked (sort of, I mean it seems to work well enough for me - although running casperjs c:\casperjs\tests\selftest.js seems to have a number of failing tests).
So to recap, the bad news is only the very latest bleeding edge casperjs works. The good news is the install is 1,2,3 simple:
Clone latest casperjs from github into c:\casperjs.
Copy phantomjs.exe (ver 2.0) to c:\casperjs\bin
Add c:\casperjs\bin to your windows path
Just in case you're using a notebook with dual graphic cards like I do: choose one of them to prevent issues. This article helped me out:
casperJS not finishing on windows
the casperJS documentation is pretty clear about it but I had no clue what to do until I read the notice above.
Fast forward to 2015... 5-steps win7 howto:
choco: PS me> iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
git: choco install git -y
phantomjs 2.0: choco install phantomjs -y
casperjs source: git clone https://github.com/n1k0/casperjs -b phantomjs-2
Add the location of casperjs/bin to PATH
Done. You can now casperjs --version and live happily ever after.
Ok guys. So I think this thread needs refreshing for 2018!
So with npm, the effort is reduced significantly. Given that you have npm installed, open terminal and go to your project:
cd your_project_name
Now install casperjs. Use --save-dev, --save, -g or none as needed:
npm install --save-dev casperjs
Now install phantomjs. To do this, you should install phantomjs-prebuilt, because PhantomJS team changed their package name:
npm install --save-dev phantomjs-prebuilt
Run your spec:
casperjs your_spec_name.js

Resources