Start jest in watch mode without executing any tests - jestjs

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.

Related

jest starts too early with --watch option?

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?

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.

Linux: How to cat stdout of a process until the end, but stop and return a non-zero code if certain string appears?

We have a tool that runs tests, but does return an error code if they fail.
The tool runs the tests after starting logging in through SSH to a custom console (not bash) and issuing a command. All tests run at once within that invocation
The logging of the tests goes to a file.
The output of the tool is roughly:
test1 [ok]
test2 Some message based on the failure
...
To stop the build, we need to look for certain strings in the output.
The output appears as the tests run.
I could capture the whole output into a file and fail at the end. But it would save quite some time to fail once the first test fails.
Therefore, I would like something like tee, but it would also kill the execution if it finds that failure string. Or, at least, it should print the output as it comes, and return non-zero if a string is found.
Is this doable with the standard Linux toolkit?
The only solution I can think of is:
Start you build process and cat its output to an output file.
Start another script that monitors this file: a loop which iterates every X seconds in search for your, lets say, forbidden words in the file. As soon as they appear, kill the build process (you may need a way to identify your build process, such as a pid file or something like this) and clear the file.
You can even put this 2 processes in a single shellscript and make them both start and stop when needed.

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.

Resources