Skip to content

How do I import an external library to my tests #2699

Answered by timotheeguerin
Onokaev asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @Onokaev, you can find docs on how to setup your test environment included how to include another library in your test host here

https://microsoft.github.io/typespec/extending-typespec/basics#testing

The test host needs to know ahead of time what are the files that are going to be needed(tsp, js, etc.) which is why you have to register those test libraries.

Example here on how to include @typespec/rest with the RestTestLibrary

import { createTestHost, createTestWrapper } from "@typespec/compiler/testing";
import { HttpTestLibrary } from "@typespec/http/testing";
import { MyTestLibrary } from "../src/testing/index.js";

export async function createMyTestHost() {
  return createTestHost(…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by timotheeguerin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants
Converted from issue

This discussion was converted from issue #2697 on November 27, 2023 19:32.