Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
spirulence opened this issue Feb 14, 2025 · 1 comment · May be fixed by #1483
Open

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

spirulence opened this issue Feb 14, 2025 · 1 comment · May be fixed by #1483
Labels

Comments

@spirulence
Copy link
Contributor

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
@alexbit-codemod
Copy link
Contributor

thanks so much cameron for finding the issue and working on the fix! you rock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants