Skip to content

[cli] 'pnpm coverage' fails with TypeError #1482

@spirulence

Description

@spirulence

Issue Description

Select one of:
[ ] Generated codemod is not correct
[ ] Bug in Codemod Studio
[ ] UI/UX improvement request
[x] Feature request

pnpm coverage which runs cli unit tests with a code coverage report, fails during report generation.

I have a branch in progress to update the vitest version in the cli application as one possible fix.

Steps to Reproduce

  1. Install and build dependencies.
  2. cd apps/cli and run pnpm coverage

Longer reproduction script against current main branch:

# codemod uses Node 20
nvm install 20 && nvm use 20 && nvm alias default 20

# pnpm is the package manager
# and turbo for monorepo support
npm install -g pnpm@9.5.0 turbo@1.13.4

# install external workspace dependencies
pnpm install

# @codemod-com/* intra-workspace dependencies are missing unless built first
# like @codemod-com/printer and @codemod-com/api-types
# the filter is to only build intra-workspace dependencies needed by cli
# cli is known as 'codemod'
turbo build --filter codemod

# turbo coverage command is not configured repo-wide, 
# so we run commands from the cli directory
cd apps/cli

# finally the coverage command
pnpm coverage

Actual Results

I see unit tests run successfully, followed by an unhandled TypeError:

> codemod@0.18.0 coverage /home/developer/gitclone/codemod/apps/cli
> TEST=1 vitest run --coverage


 RUN  v1.1.0 /home/developer/gitclone/codemod/apps/cli
      Coverage enabled with v8

stderr | test/credentialsStorage.test.ts > CredentialsStorage > when .codemod directory does not exist > should return null without throwing an error
Error: libsecret-1.so.0: cannot open shared object file: No such file or directory 

Codemod CLI uses "keytar" to store your credentials securely. 
Please make sure you have "libsecret" installed on your system. 
Depending on your distribution, you will need to run the following command 
Debian/Ubuntu: sudo apt-get install libsecret-1-dev 
Fedora: sudo dnf install libsecret 
Arch Linux: sudo pacman -S libsecret 

If you were not able to install the necessary package or CLI was not able to detect the installation please reach out to us at our Community Slack channel. 
You can still use the CLI with file-based replacement that will store your credentials at your home directory.

 ✓ test/api.test.ts (30)
 ✓ test/credentialsStorageKeytar.test.ts (4)
 ✓ test/credentialsStorage.test.ts (4)

 Test Files  3 passed (3)
      Tests  38 passed (38)
   Start at  18:10:15
   Duration  2.15s (transform 911ms, setup 73ms, collect 3.42s, tests 161ms, environment 4ms, prepare 590ms)


⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
TypeError: this.toSlices is not a function or its return value is not iterable
 ❯ V8CoverageProvider.reportCoverage ../../node_modules/.pnpm/@vitest+coverage-v8@1.6.0_vitest@1.1.0_@types+node@18.11.9_jsdom@23.2.0_terser@5.38.1_/node_modules/@vitest/coverage-v8/dist/provider.js:2296:34
 ❯ Vitest.reportCoverage ../../node_modules/.pnpm/vitest@1.1.0_@types+node@18.11.9_jsdom@23.2.0_terser@5.38.1/node_modules/vitest/dist/vendor/node.i3Lxw5di.js:8338:7
 ❯ Vitest.start ../../node_modules/.pnpm/vitest@1.1.0_@types+node@18.11.9_jsdom@23.2.0_terser@5.38.1/node_modules/vitest/dist/vendor/node.i3Lxw5di.js:8031:5
 ❯ startVitest ../../node_modules/.pnpm/vitest@1.1.0_@types+node@18.11.9_jsdom@23.2.0_terser@5.38.1/node_modules/vitest/dist/vendor/node.i3Lxw5di.js:15035:5
 ❯ start ../../node_modules/.pnpm/vitest@1.1.0_@types+node@18.11.9_jsdom@23.2.0_terser@5.38.1/node_modules/vitest/dist/cli.js:142:17
 ❯ CAC.run ../../node_modules/.pnpm/vitest@1.1.0_@types+node@18.11.9_jsdom@23.2.0_terser@5.38.1/node_modules/vitest/dist/cli.js:98:3

Expected Results

I expected to see a coverage report like this:

Image
(out of date image but the overall format is correct)

Technical details

  • NodeJS v20.18.3
  • Ubuntu 24.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy