-
Notifications
You must be signed in to change notification settings - Fork 284
New testing framework #7151
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
base: main
Are you sure you want to change the base?
New testing framework #7151
Conversation
All changed packages have been documented.
Show changes
|
You can try these changes here
|
```ts title="test/tester.ts" | ||
import { createTester } from "@typespec/compiler/testing"; | ||
|
||
const MyTester = createTester({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be helpful to mention importLibraries()
needs to be called to actually import these in a program, given the older test wrapper did this automatically.
strictEqual(Foo.name, "Foo"); | ||
``` | ||
|
||
2. Using flourslash syntax to mark the types you want to collect (`/*foo*/`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows you to get types that can't be decorated, right? Maybe worth calling that out (otherwise it's not clear why you'd use this over @test
)
If you are using VS Code, you can install the [Node test runner](https://marketplace.visualstudio.com/items?itemName=connor4312.nodejs-testing) to run your tests from the editor. This will also allow you to easily debug your tests. | ||
|
||
After installing the extension, you should be able to discover, run, and debug your tests from the test explorer. | ||
[Testing](./testing.mdx) see documentation for adding tests to your library. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A migration guide might be useful (or even point back to this PR so someone see the changes that need to be made)
|
||
@test op ${t.op("get")}(): EmbeddingVector<int32>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: We don't need the @test
decorators since we're using t.<entity>
- but cool to see you can use them both together and nothing bad happens! (Looks like @test
is still used a lot in this file)
Co-authored-by: Christopher Radek <14189820+chrisradek@users.noreply.github.com>
|
||
export interface TestCompileOptions { | ||
/** Optional compiler options */ | ||
readonly options?: CompilerOptions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to compileOptions
Tentative improvement of the testing framework for TypeSpec using the idea here https://gist.github.com/timotheeguerin/e218fd2079fb331db31bc0a5a70dc539
Todo: