Debug jest tests

Source: https://stackoverflow.com/a/63909711

You do not need Chrome for Jest tests.

The simplest solution I found is to use VS Code JavaScript Debug Terminal.

And it works with Typescript and Nrvl.Nx work-spaces out of the box.

  1. Open the command palette and start Debug: JavaScript Debug Terminal:
enter image description here
  1. Run tests in that terminal in a Watch mode npm test -- --watch. (or yarn test --watch if you are using yarn)
  2. Set a break-point in your file.
  3. Make any change in a file you want to debug and save.
  4. watch will run Jest tests against modified files.

When you want to narrow down the number of files run by the –watch, press p in the terminal and enter a pattern, which is just a part of the file name you want to test and hit [Enter]

To limit it to a single test in a file – focus it with f, so change it(…) to fit(…)

xUnit MemberData only returns one test

I found this issue when the test data is very large (some large JSON and GraphQL query strings). For some reason MemberData only generates one test, probably some limitation or an edge case that xUnit does not handle.

In this case, the way to solve this problem is to generate a very small test parameter, and then in the test run the generation code to create other test values. Then xUnit will work correctly.

IIS Error: This configuration section cannot be used at this path …

Reference SO question and answer:

https://stackoverflow.com/questions/9794985/config-error-this-configuration-section-cannot-be-used-at-this-path

Try to fix this by installing “Internet Information Services” => “World Wide Web Services” => “Application Development Features” from “Turn Windows features on or off”

Maybe you need to install ASP.NET 4.8, or something similar, try out few things depending on your project.

Cannot connect to MSSQL database from .NET 6 application

If you encounter SSL error when a .NET 6 application tries to connect to the MSSQL database

Microsoft.Data.SqlClient.SqlException : A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 – The certificate chain was issued by an authority that is not trusted.)
System.ComponentModel.Win32Exception : The certificate chain was issued by an authority that is not trusted.

Not sure why, it might be that the new libraries are more strict regarding security. A workaround is to add TrustServerCertificate=True to the connection string.

Docker desktop using all the RAM

Some applications will use as much resources as possible, like Elasticsearch.

If you are running Docker for development and it uses up all your resources because of such application, you can configure the Docker backend to limit the amount of resources it can use.

If your Docker desktop is using WSL2 as backend, create a .wslconfig file in your user home folder in Windows with the following content

[wsl2]
memory=6GB
processors=4

Then, restart the WSL backend in Powershell

Restart-Service LxssManager

This will also restart Docker Desktop.

This will limit the resources Docker will use to only 6GB RAM and 4 core processors, leaving resources for your other applications and development tools.

Cannot restore internal NuGet packages

When working with projects that has dependencies on an internal NuGet registry, you may need add credentials for the internal registry so that NuGet can fetch the packages.

If you restore in Visual Studio, it’s possible that VS will ask you to provide credentials (not yet tested).

If you try to restore or build using the command line, it may fail with unauthorized error.

To resolve, modify nuget.config file, either in the same folder of the solution file, or modify the global nuget.config file.

<packageSourceCredentials>
<MyPrivateNugetRegistry>
<add key=”Username” value=”Your username here” />
<add key=”ClearTextPassword” value=”your password/access token here” />
</MyPrivateNugetRegistry>
</packageSourceCredentials>