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

[Bug]: Library templates do not follow guide and result in non-working tests #3647

Closed
4 tasks done
stefan-schweiger opened this issue Jun 24, 2024 · 2 comments · Fixed by #3605
Closed
4 tasks done
Assignees
Labels
bug Something isn't working docs Improvements or additions to documentation triaged:core
Milestone

Comments

@stefan-schweiger
Copy link

stefan-schweiger commented Jun 24, 2024

Describe the bug

When you initialize a new library as described here and try to run the tests it fails with Error: Cannot find module '~/source/typespec-test/dist/test'. Also overall the code produces by the tsp init --template library-ts command is not very similar to the one described in the documentation. For example there is no vitest installed and no config files for it produced. And even when trying to adapt it to the code described in the docs it still does not work.

I think it's important to have a working base template or example project how to create libraries and it's a pity that trying to extend typespec immediately throws such roadblocks in your way.

Environment:

TypeSpec compiler v0.57.0
macOS 14.5
npm 10.5.2
node 22.3.0

Reproduction

  1. tsp init --template library-ts
  2. npm install
  3. npm run build
  4. npm run test

Checklist

@stefan-schweiger stefan-schweiger added the bug Something isn't working label Jun 24, 2024
@bterlson
Copy link
Member

That is a pity. The templates are a bit stale, will update them!

@bterlson bterlson added the docs Improvements or additions to documentation label Jun 24, 2024
@markcowl markcowl added this to the [2024] July milestone Jun 24, 2024
@timotheeguerin
Copy link
Member

I believe this is an issue with node 22 test framework introducing a breaking change. This pr supposed to fix it but seems like is having some issues, will look into it https://github.com/microsoft/typespec/pull/3605/files

@timotheeguerin timotheeguerin self-assigned this Jul 5, 2024
github-merge-queue bot pushed a commit that referenced this issue Jul 8, 2024
fix [#3647](#3647)

With node 22 the --test needs a glob to find files to test. As the docs
a written the tests don't run or pass. This fixes it for me.

---------

Co-authored-by: Timothee Guerin <tiguerin@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working docs Improvements or additions to documentation triaged:core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants