jest starts too early with --watch option? - jestjs

during development I have a npm script I run that is just
jest --coverage=false --watch
However when I start typing in one of my file (and have not saved yet) jest directly starts executing again which usually leads to problems at test execution since I have not completed typing and syntax is off or sth. And then I need to wait for jest to finish, save my file and then see the real results. That kinds of destroys my workflow.
I cannot image that this is supposed to be like this but couldnt find really anything how to have a better workflow, since I want my tests not only to run at commit but at save.
How can I achieve that?

Related

Start jest in watch mode without executing any tests

I have a lot of test files in my project, and I would like to know how can I start jest in watch mode without executing any tests automatically?
Because, as of now, when I start jest in watch mode it starts executing some long-running tests from many .spec.ts files, and I don't want that. I just want to start it, and wait for me to enter regex to filer files or whatever.

How to run multiple files at the same time?

Okay, so, I have 2 different files at the moment that I have made in Visual Studio Code. I am using node.js & discord.js , I'm attempting to make a discord bot. When I run the terminal and run "node ." (its how I usually activate my bot and run its commands, it only activates my index.js file and not the other file, which is called help.js. I can't seem to make both of these files be run at the same time, its either I activate "index.js" or "help.js" , and future thing is, I'm most likely going to make more different files and want them to run at the same time. Sorry if I wasn't clear enough, I didn't really know how to say it. I'm pretty much a beginner in programming and stuff :P
Assuming you didn't do a fancypants module structure (aka, assuming you didn't put exports in help.js), all you have to do is throw this line at the top of index.js:
require('./help.js');
(assuming help.js is in the same folder as index.js)
Then keep running node . as usual.

cucumber-js executes all scenarios but it gets stuck in the command propmt

When I start the command to run cucumber, it executes all of the scenarios and all of them pass. However, when it finishes it doesn't exit the process, but remains stuck until I press Ctrl + C. This is important as I want to use it as a command in Jenkins, and it happens that in Jenkins it wouldn't finish ever given what I have just mentioned.
As you can see, the expected behaviour is the one from my unit test. Just exit the process, without me having to Ctrl + C.
According to the (CLI reference), you should be able to add "--exit" to the end of your command. So for me, it like this:
npx cucumber-js features/ -r steps/ {other cli things} --exit
There's some helpful hints there on finding out why the issue is occurring and fixing it, as well.
This worked for me:
I was using the AfterAll GlobalHook to tear down my in memory database.
After changing it to After (after each scenario), my cucumber-js task exit normally

Profile a gulp build with spy-js

From one of the comment in the webstorm blog article, it says one can debug a grunt program by creating a script file and invoke with grunt. I have a gulp setup I like to profile. So, I created a script file with
var gulp = require('gulp');
require('./gulpfile');
gulp.start.apply(gulp, ['default'])
when I run this with a spy-js run session, it executes and ton of trace info. The traced application window shows it ran correctly as I could see the logs. But, I cannot find any of my methods in trace run window. Where should I look for say, a function called from my gulpfile.js? I tried quick search by clicking on middle window and start typing. But I cannot find any of my method.
Another qn, how to go to the next hit in the quick search window. As in the attached image, it hit one result, but I want to go to the next. How?
The best way would be to use capture exclusions to get rid of the noise from the files you're not interested in.
On the screenshot above, single file filter is applied (meaning that nothing but this file will be captured), so after applying such filter and restarting the session you will only see the code from gulpfile.js. You can use glob patterns to include/exclude files you need. I suspect in your scenario excluding all node modules should be enough. There's a shortcut to create such filter, just right click on the root node inside the events pane and select "Mute node modules":
If you're interested in tracing some of the node modules, you can modify the filter to exclude just those you're not interested in. You can also create filters for individual node modules by locating one of their functions in the stack tree and using "Mute this node module" context action.

Problems with coffeeescript breakpoints in WebStorm

Is there anyone who has good experience with debugging larger coffee script projects in Webstorm?
I have a nodejs project having 200K+ lines and it driving me crazy debugging that. 50% of breakpoints set in coffeescript files are hit, but in most cases I need to find a generated .js file and put the breakpoint in the respective place. That .js-file breakpoints work well with 100% accuracy. But managing at the same time js and coffee script files is really pain in the neck. Of course I might have case when there is one file and breakpoint in one coffee line works well and on the next line doesn't.
I'm using standard coffee transpiler (1.8, same with the previous versions), but I tried as well coffee-script-redux and result were the same.
Any good or bad experience with that?

Resources