Skip to content

Instantly share code, notes, and snippets.

View kermitsxb's full-sized avatar
🤩
Learning new things

Stocki kermitsxb

🤩
Learning new things
View GitHub Profile
@kermitsxb
kermitsxb / NEST-FULL-COVERAGE.md
Created August 30, 2022 07:23
NestJS coverage configuration for combined unit & e2e test runs

Setup

  1. Edit package.json Jest configuration as shown below. The big points are to ensure you have a json reporter and to ensure your coverage is stored in a unique directory for unit tests (in this config its coverage/unit. Also, add the development dependencies shown as they are required for the merge script.
  2. Edit your e2e configuration (test/jest-e2e.json) as shown below. The required "trick" was to ensure that rootDir's subtree includes paths for the e2e tests as well as an source you want to generate coverage for. Using the parent directory includes both test and src so this works. I tried many other methods, like setting collectCoverageFrom to ../src, none of them worked. It appears you must use the parent directory and exclude everything you don't want. Note that it also uses a unique directory for its generated coverage data (coverage/e2e).
  3. Add merge-coverage.ts shown below to your project and run it after you've ran both test sets generating coverage.
@kermitsxb
kermitsxb / create_docker_compose_basic_auth_string_for_traefik.sh
Created February 24, 2022 20:59 — forked from movd/create_docker_compose_basic_auth_string_for_traefik.sh
Generator to create basic authentication string for traefik (docker-compose.yml and .env)
#!/usr/bin/env bash
command -v docker >/dev/null 2>&1 || { echo >&2 "I require Docker but it's not installed. Aborting."; exit 1; }
echo "Basic auth for traefik >= v1.7"
read -p "User: " USER
read -p "Password: " PW
# Pull httpd:alpine image (small and includes httpasswd)
docker pull httpd:alpine >/dev/null 2>&1

[Linux Mint 17.2] Install MyCLI and grc

Install both grc and mycli

$ [sudo] apt-get install grc && \
> curl https://packagecloud.io/gpg.key | [sudo] apt-key add - && \
> [sudo] apt-get install -y apt-transport-https && \
> [sudo] sh -c \