I am new to React and attempting to use npm test.
From the docs, it is my understanding that every time npm test runs, it starts the watcher. The watcher is supposed to display a list of commands titled "Watch Usage". This includes commands such as a, f and q.
When I run npm test, watcher appears to work because it runs the tests and reruns them if I save a file.
However, it does not display the "Watch Usage" list and if I type any of the "Watch Usage" commands, nothing happens.
How can I enable the "Watch Usage" commands?
I was attempting to run this command in Git Bash. I have not found a solution to make it work in Git Bash.
However, you can instead run the command in cmd.exe and it will work properly.
The Jest VSCode extension can also be helpful.
There is a problem with running Jest inside Git Bash on Windows. The terminal codes for updating the screen are not correctly handled, and I've been unable to find a reason or fix for this searching Google.
If you run npm test from a DOS prompt, then it seems to work fine, but if you run npm test from a Git Bash prompt the progress feedback from Jest is missing.
You can enable colors by running npm run test -- --colors which gets Jest to output the color status for tests in Git Bash, but strangely the colors are working but the progress is still not shown.
The only successful work around that I've found is running Jest from inside winpty if you're using Git Bash.
winpty npm.cmd test
So what I do is add an alternative npm script to my package.json file for running on Git Bash inside Windows.
"wintest": "winpty npm.cmd run test",
Then you can just run that instead.
npm run wintest
It's not a perfect solution, but at least you can see the progress correctly.
You can activate watch mode, modify your package.json:
"scripts": {
"test": "jest --watch",
}
run npm test
Related
I'm just starting to learn about how JavaScript, HTML, and Electron all work, and I want to know what runs electron . in the "scripts" -> "start" of package.json, because I can't tell what does and that kind of wizardry makes me nervous.
According to the man pages for npm, what npm start does is that it reads the package.json, looks at the script under "scripts" -> "start" -> some_script, and then runs some_script. Sometimes, some_script is something like node foobar.js, which makes sense to me, since I can run that from the command line. NodeJS is executing foobar.js. However, in the case of the electron-api-demos, some_script is electron .
You can download and run electron-api-demos via
git clone https://github.com/electron/electron-api-demos
cd electron-api-demos/
npm install && npm start
In order to try to figure out what is running electron ., I've run it in the node shell, and I've tried running node main.js. I've even tried opening up the node shell and running
electron-api-demos#2.0.2 start $DIR/electron-api-demos
electron .
(which is exactly the output of npm start). None of them worked, because none of them started up the Electron application. At this point I'm very puzzled at how, exactly, the start script gets executed at all.
So I guess my question is: does there exist a command (that I can use on the command line) to start up this Electron application, without using npm? If not, what is npm calling to start up this Electron app?
I apologize if this question has been asked before, but I all the sources I found didn't seem to go into any further detail about what, exactly, is done when npm start is run and how it executes electron . . Thank you for your time!
Command line interfaces installed with npm are put in the node_modules/.bin/ directory. You can't just run them from the command line because that directory isn't in your PATH (unless you put it there, or you installed it globally).
So, if you want to run electron without npm start, you can run ./node_modules/.bin/electron .. Since this is a bit verbose, newer versions of npm provide the command npx to run things without the ./node_modules/.bin/ part, so npx electron . also works.
Since npm scripts often use the packages you've installed, they automatically add node_modules/.bin/ to the PATH before running your command. As a result, the start script can just reference electron directly.
npx can do some other cool things too – npm has a blog post about it.
When you run npm start , it by default run command corresponding "start" key of script property of package.json like
"script":{
"start": "ng serve",
"launch":"electron main.js" or "electron ." // main.js located in the same dir
"test": " ng test"
}
same when you run npm run launch it will trigger the command corresponding of the "launch" key of script property of package.json file. like run electron main.js command and your application will launched.
so if you want to run the your electron application directly like electron main.js then install the electron module globally using command npm install electron -g then simply run the electron main.js command and your application will start.
I am following the "gulp quick start" and everything is getting installed without error messages neither warnings. But when I try to check the gulp version on the end of the "gulp quick start" it returns
'gulp' is not recognized as an internal or external command,operable program or batch file.
The gulp quick start: GULP
When I check the first things in the "gulp quick start" the "check for node,npm and npx" it all works fine. I am getting normal responses.
The next step is installing gulp
When I install gulp evereything goes whell, the files are being created there our no error/ warnings displayed.
BUT when I am trying to run a gulp command on the end of the installation to test if gulp works. it returns gulp' is not recognized as an internal or external command,operable program or batch file.
I tried installing it multiple times. I have no idea what i am doing wrong.
Any help is welcome.
My device is running windows 10
I have no idea why but... my npm was broken.
I tried to download something with npm but that did not work ass well so I figured my npm was broken.
When I reinstalled npm everything worked fine.
Trying to debug an NPM script from within Webstorm. The application runs through the NPM scripts, but when debugging the script it always crashes. I know that there is the flag $NODE_DEBUG_OPTION, but adding that doesn't seem to work.
Script:
"dev": "npm run dev:server & npm run build:client:watch",
"dev:server": "npm run build:server:watch & nodemon --harmony lib/server",
"build:client:watch": "WEBPACK_DEV=true NODE_ENV=development STACK=local node lib/server/webpack",
"build:server:watch": "npm run transpile:watch -- -d lib/common src/common & npm run transpile:watch -- -d lib/server src/server",
"transpile": "BABEL_ENV=node babel",
"transpile:watch": "npm run transpile -- --watch",
According to Webstorm: To debug the "dev" script, make sure the $NODE_DEBUG_OPTION string is specified as the first argument for the node command you'd like to debug. For example: { "start": "node $NODE_DEBUG_OPTION server.js" }
But even when adding this in different places it will still give me an error. Any suggestions?
For anyone reading this in 2020, you just need to right-click the script in the NPM panel and select "Debug ".
You can then set breakpoints in the script and debug in the Debug panel panes, Debugger, Console, etc..
To re-run the script, click the bug icon in the Debug panel.
Probably you are using node8, where this will not work because in node 8 V8 debugger API had been superseded by the V8 inspector API. For more info look at this issue, In previous versions of nodejs this works. For node 8 you should check the WebStorm site, they have information about how to work with the new inspector protocol https://www.jetbrains.com/help/webstorm/run-debug-configuration-node-js.html?search=node
I am trying to run my protractor test case in Bamboo CI but it throws an installation error.
I am able to install node modules using npm task but somehow I am not able to install and run protractor in my bamboo plan. Is there a different way of doing it or I am doing something wrong.
Please find attach the snapshot from my bamboo plan :
Npm install
Protractor Task
And my error log is as follow
/tmp/RDMPDEV-MAP-JOB1-91-ScriptBuildTask-6009702493071779000.sh: line 1: protractor: command not found
Please advice
You did not mention commands for protractor and web-driver installation. Do following:
Write below commands into Command* text filed under npm configurations section. Either put all commands separate by a comma or add one more configuration section if you could see any such option. or check in advanced options
Commands:
install -g protractor
webdriver-manager update
Write 'webdriver-manger start' as first line in script body and then write 'protractor conf.js'
You should mention all test spec in conf.js file and run conf.js file from script body.
Script body looks like:
1. webdriver-manager start
2. protractor conf.js
You can also trigger protractor tests in bamboo via angular cli command e2e.
Definition of e2e in package.json
"e2e": "ng e2e --no-serve --base-href"
Please refer below screenshot showing this configuration in bamboo.
Remember to add commandline parameter to e2e command in bamboo as required like --base-href
I'm having trouble installing Selenium and I'm completely lost
I followed this documentation by the letter and looked around the site and the web for a while now and came to a dead end. Like I said in the title I'm using Chrome and Javascript for this.
[Documentation]http://selenium.googlecode.com/git/docs/api/javascript/index.html
So true with the documentation, the first thing I did was installing the "selenium-webdriver" which I opened up cmd and typed "npm install selenium-webdriver". It responded with saying what directory it installed and the version it installed which was 2.42.1.
After this I installed the ChromeDriver 2.10 from their home download page. After this I unziped the file and moved chromedriver.exe to "node_modules\selenium-webdriver\ChromeDriver" and added it to my systems environmental variables.
So then the next step was to test it, so I copy pasted "npm test selenium-webdriver" into the cmd and got this following error. [Error]http://imgur.com/xIYE3oa I also tried running ChromeDriver after I kept running into this error and tried it again to get the same result. It doesn't tell me anything other then...
Starting ChromeDriver on port 9515
Only local connections are allowed.
Thank you in advance.
First, make sure that you have Mocha installed by running npm install mocha.
You will then want to edit the "scripts" section of the package.json file for selenium-webdriver to match the following:
"scripts": {
"test": "mocha -R list --recursive test"
},
After completing those two steps, you should be able to run your tests with the npm test selenium-webdriver command.