I have an automated process to do the following (I have a Jenkins setup to do the following):
clone project
npm install
grunt
The grunt execution fails because of the following error
[PhantomJS 2.1.1 (Windows 8 0.0.0)]: Disconnected (1 times), because no message in 10000 ms.
PhantomJS 2.1.1 (Windows 8 0.0.0) ERROR
I found that setting browserNoActivityTimeout: 10000 in karma.conf.js file I solved the problem. But I did it manually (edited the conf file and added an entry).
As I have an automated process, I want to be able to set browserNoActivityTimeout: 10000 through command-line (example like npm config set registry= so that grunt executes properly.
Is there any way to do this?
Copy your original karma.conf.js into a separate karma-no-act-timeout.conf.js file (probably name it better than I did here), drop browserNoActivityTimeout: 10000 in there and then bootstrap the command lines in your package.json file like this:
"scripts": {
"unit-test": "karma start ./config/karma.conf.js",
"unit-test-no-timeout": "karma start ./config/karma-no-act-timeout.conf.js",
},
Now you can call either the original script using:
npm run unit-test
or call the one with browserNoActivityTimeout using
npm run unit-test-no-timeout in the command line.
As you noticed, these karma.conf files are in config folder. If your structure differs, update your npm script commands.
Related
I have an Electron application that run into a node.js server. And I also want to work with "nodemon" for live execution node server.
This 2 previous sentences getting up 3 different execution possible into start key in package.json file :
electron .
node server.js
nodemon server.js
I would like quickly switch between those execution command. I can create a Run/Config template with PhpStorm but all of those save command run with the same package.json file that wrote the start command.
How can I use the same package.json for working with 3 execution environments?
I've updated my project to use node 6.11.3. When I now try to start a npm-script by using the Run-configurations provided from IntelliJ, I always receive the following error:
Error: Failed to replace env in config: ${NODE_EXE}
Important: This error appears only if I start npm from within my project. If I use the windows cmd, the error doesn't appear.
What could possibly have changed between node 6.11.2 and 6.11.3? Because with the prior version, everything worked fine.
A workaround for me is to add the NODE_EXE variable to my run configuration, but In my opinion, that shouldn't be needed, because it worked in 6.11.2 too.
Looks as if you have ${NODE_EXE} variable set in one of your npmrc files (see https://docs.npmjs.com/files/npmrc#files), and it can't be properly expanded for some reason when you run your script in the IDE.
is the issue specific to certain project?
how many npm versions do you have installed? Please check that npm chosen in Node.js Interpreters dialog is the same as you use in cmd shell?
please create an env.js file with console.log(process.env) and try running it via npm ("env" : "node env.js") in both cmd console and WebStorm - what is the result?
My goal is to run mocha unit tests by Atom, which is installed on Windows and also my src code resides. this should work independently from my Meteor App which is running on a different (Linux) machine.
Basically my setup is like this:
I have my repo and sourcecode:
c:\Users\Me\repos\meteor
My tests are inside:
c:\Users\Me\repos\meteor\tests
I have Node:
c:\Program Files\nodejs
installed with "npm i -g mocha --save-dev"
And i try to use this package https://github.com/Tabcorp/atom-mocha-test-runner but i can switch to another package if necessary.
What I've tried so far:
I edited my settings for the atom-mocha-test-runner:
Mocha command: C:\Program Files\nodejs\node_modules\mocha\.bin\mocha
Mocha command: C:\Program Files\nodejs\npm mocha
But each time i try to run my test via dropdown menu (Run Mocha Test), i get this error:
Mocha Test Results:
Node binary: C:\Program Files\nodejs\node.exe
Root folder: C:\Source\Repos
Mocha command: undefined
Path to mocha: mocha
Debug-Mode: false
Test file: tests\unit\first.js
Selected test: should return url
Failed to run Mocha
spawn mocha ENOENT
Anyone know what i miss or do wrong?
Still having no idea about why the package isn't working, I'm going to give a cop-out answer. If we figure out how to make it work, you can accept that answer instead. process-palette gives you the ability to run highly specific command-line instructions from Atom commands. Here's an example of a command that runs mocha in the project path for the current file with the same hotkey and also conveniently organized into its own menu item:
The disadvantage of this approach is that you have to know how to use the external program yourself. Packages like mocha-test-runner are designed to remove that need from the user, but as we can see here, sometimes the package doesn't know what it needs to be doing. The disadvantage is mitigated by the fact that you only have to learn the command for long enough to set up the configuration to run it, and from that point on it's very easy.
Advantages versus other packages include the ability to precisely control what's going on. Say you have multiple top-level folders in the current project, and they have different test suites. A package like mocha-test-runner can get the path from the active file, or from the project. If the developer chose to grab the project path, then you're going to have trouble running individual test suites. With the configuration I've shared, the command will always be run in the absolute path of the current file's project folder, so the tests will be run for whichever file you're working on at the time.
I have globally installed jasmine by running npm install jasmine -g.
Running jasmine -v gives me
jasmine v2.5.0
jasmine-core v2.5.0
I have then, as per the docs, run
jasmine init
jasmine examples
This created the expected /spec directory and the spec/support/jasmine.json file.
I am under the impression that if I now run jasmine I should see some test output in the console. Instead it simply thinks about it for a second and then does nothing.
I'm running node v4.5.0 on a Windows 7 machine in a Git Bash terminal. I've tried running it from the Windows cmd prompt as well but that doesn't work either.
well jasmine does run, but it doesn't report anything when you run jasmine alone. (you can confirm that by putting console.log inside describe functions and see that indeed it will log.)
download the latest release, it will have an html file that you can run which will do all the work for you.
https://github.com/jasmine/jasmine/releases
basically running jasmine requires a boot.js file for configurations. a jasmine-html.js file for the html reporter. you can figure out everything yourself by running the SpecRunner.html.
my personal preference is to use protractor and have the reporter configured in the protractor.config file.
if you want to run jasmine and have it run, you need to add your own boot.js and reporter, and loading them first thing before the spec in the jasmine.json file.
{
"spec_dir": "spec",
"spec_files": [
"boot.js",
"**/*[sS]pec.js"
],
"helpers": [
"helpers/**/*.js"
],
"stopSpecOnExpectationFailure": false,
"random": false
}
It's a bug in jasmine
https://github.com/jasmine/jasmine-npm/issues/90
Use version 2.4
npm install -g jasmine#~2.4
I have a command line tool written in node. I'd like to:
Have the app be able to load its dependencies and work. Currently, after npm install -g <somemodule> that module is still not available. Things didn't used to work this way.
Not have to run npm link on every folder, as I have read in the NPM 1.0 docs. The above docs also talks about $PATH, which seems unrelated to the topic as I care about node modules, not binaries.
How can/should a node command line tool handle its dependencies so that the command line tool can run from any directory?
You can add following in the main file of your node.js app, assuming your file name is node-binary.js.
#! /usr/bin/env node
// your app code
console.log('TEST node binary');
And, in package.json file you need to specify which is the entry point of your app
...
"preferGlobal": "true",
"bin": {
"node-binary": "node-binary.js"
},
...
and run the command npm link in the app directory. You should now be able to use node-binary command from any directory.
Hope that helps... :)