Jest is hung there - jestjs

I have a project using jest. It's running good historically. After 1 year when I open it, somehow jest is hung. No info, no error, not proceed. (See pic) Any insights?

Jest runs the tests with a multithreaded approach that might sometimes run into a deadlock. The same happened to me on Git-bash when I used to run my projects in a windows environment. Try adding a
-- -i
to your test command to run it without using multithreading and see if it solves the problem.

Related

Javascript module imports takes too long

I've created up a nodejs mono-repo project using tuborepo and the kitchen-sink template.
Here I have some applications, the code that I am going to release, and some packages, basically are shared functions and logic that the applications may or may not use.
It worked well, until some days ago, when I've found a strage behavior in some of my apps.
I have to make some changes to an application, so I've opened up Visual Studio Code, I've run yarn dev, and I was ready to code, but when I've started the application that need to update, I've noticed that it won't start, usually it takes some time, like 5 seconds at most, but this time it was taking up to 30-40 seconds util the node process exited.
I've tried with another application that is very similar but differs in some way, and I've encountered the same issue, so I've decided to create and empty test suite check if everything was still working fine, and it did, I mean the node process was not crashing and I've had the output I expected.
Then I've started to import from the packages the modules I needed, and I've noticed that a particular one causes this weird problem.
This module depends on other packages, and its main purpose is to serve up classes and functions that may be use from the application.
The problem is: when use the import ... from ... from the application code, the process hangs, then sometimes it can start properly so the code is executed, sometimes the node process exits, without an error message and with a status code of 0.
I've tried to use the process.on("uncaughtException") and process.on("unhandledException") but neither of them are ever fired, segault-handler doesn't help either since it does not report anything.
I've checked the code of this module, and it does not execute some functions or perform logic while it is importing, so I don't think it has to do with slow running functions.
I have only one theory, circular dependencies so a js file to includes another js file which itself includes the first one? but I don't think so since the code used to work just fine.
I've to use a backup of the code I have when It worked, but still, I do have the same error
I was wondering guys if you could please give me some hints to fix the bug, or if you had a similar issue explain how to solve.

Testcafe - sending false errors/dies after running 100+ tests in a row

I am creating an automation testing platform, and I wrote a code which executes around 300+ tests in a row.
I am currently running the tests on my local machine. After around 10-20 tests the testcafe either stops working or giving false error or starts slowing down and not navigating to the right page therefore can't find any of the selectors I tell it to look for.
I know this to be false errors since when I only run these tests on their own testcafe is not doing that anymore and the tests pass successfully with no errors at all.
Any idea whats going on? Is this a problem with my local machine?
The cause of the issue is unclear. Please create a separate issue using the following link https://github.com/DevExpress/testcafe/issues/new?assignees=&labels=TYPE%3A+bug&template=bug_report.yaml and share an example that demonstrates the issue.
OK I found the issue in my code. I took a lot of screenshots per test and didn't clear them after each run which inflated my memory causing node and testcafe to crash.
Thanks for all the help

Cannot run test block in IntelliJ with Jest if api included

This is an issue I recently run into when I did a block run for the test file. This is a react project with redux, there are some APIs I directly hit into. It works before, but now the API cannot be reached and fail the tests. I set environment variables to export NODE_TLS_REJECT_UNAUTHORIZED=0, but got no luck. I can run the file by calling the command we use cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 jest , but the IntelliJ block run fails anyway. Of course, if there is no API, it works well. I'm wondering what's the reason behind it and how to fix this. This bothers me a lot, 'cause we have tons of tests, block run is very helpful for debugging.

Having nodemon and debugging both working in a WebStorm run configuration

This is a problem I have never really been able to sort and have come across a few times so I thought I'd ask on here to see if there is a solution.
I am currently building a NodeJS(koa) application using babel to transpile the ES6 code. I have setup a run configuration which looks like this:
This setups a debug configuration in order for me to debug my ES6 code.
This works great but I want the debugger to be able to run using nodemon so that when i make changes to the code, the run configuration restarts the server but keeps the debugging functionality. Is this possible from a run configuration or does it have to be done from the command line? At the moment I can only run the debugger OR nodemon... not both at the same time.
Thanks!

How to debug tests with karma.js + require.js

I have a setup basically described here - http://karma-runner.github.io/0.8/plus/RequireJS.html
Problem is that I can't see source files of my tests in Chrome dev tools. So I can't debug it. Adding debugger; works but it is very uncomfortable, almost unusable since I can't browse any other file except the one with debugger; currently fired
Seems like karma load files, parse them, wrap each test and then unload files before run.
ng-boilerplate has a grunt build that will put all your plain js files into a build directory for testing and debugging.
Take a look at the Gruntfile and karma/karma-unit.tpl.js for how this is done.
Running grunt watch will leave your browser in a state where you can debug all your tests. Just click the debug button, set your break point(s) and reload the page.
Suddenly, you are debugging any or all your js files.
If you need to debug your test deeply, this is generally an indicator of badly organized code or badly made unit test. If you follow a TDD workflow, taking small step will help you prevent any major issue with your code. I warmly recommend you watch this video: http://blog.testdouble.com/posts/2013-10-03-javascript-testing-tactics.html?utm_source=javascriptweekly&utm_medium=email (it doesn't use Karma, but you should watch it for the workflow/the principles presented)
Then, if you really want to debug your test code, nothing beat the browser. As so, you should set up your test in a manner it can be runned both in Karma and the browser. We implemented this for QUnit, Jasmine and Mocha on the Backbone-Boilerplate. Feel free to base yourself on these settings to set up your own environment.

Resources