microsoft / typespec

https://typespec.io/
MIT License
3.87k stars 174 forks source link

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

Open stefan-schweiger opened 1 week ago

stefan-schweiger commented 1 week ago

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

bterlson commented 1 week ago

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

timotheeguerin commented 8 hours ago

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