Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .chronus/changes/deprecate-old-testing-framework-2026-6-11.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
changeKind: deprecation
packages:
- "@typespec/compiler"
- "@typespec/http"
- "@typespec/rest"
- "@typespec/versioning"
- "@typespec/json-schema"
- "@typespec/xml"
- "@typespec/events"
- "@typespec/sse"
- "@typespec/streams"
- "@typespec/html-program-viewer"
- "@typespec/library-linter"
---

Deprecate old testing framework (`createTestHost`, `createTestRunner`, `createTestWrapper`, `createTestLibrary`, `BasicTestRunner`, `TypeSpecTestLibrary`, etc.). Use `createTester` from `@typespec/compiler/testing` instead.
4 changes: 2 additions & 2 deletions packages/compiler/src/testing/test-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { addTestLib, StandardTestLibrary } from "./test-compiler-host.js";
import { createTestWrapper, resolveVirtualPath } from "./test-utils.js";
import { BasicTestRunner, TestHost, TestHostConfig, TypeSpecTestLibrary } from "./types.js";

/** Use {@link createTester} */
/** @deprecated Use {@link createTester} */
export async function createTestHost(config: TestHostConfig = {}): Promise<TestHost> {
const testHost = await createTestHostInternal();
await testHost.addTypeSpecLibrary(StandardTestLibrary);
Expand All @@ -23,7 +23,7 @@ export async function createTestHost(config: TestHostConfig = {}): Promise<TestH
return testHost;
}

/** Use {@link createTester} */
/** @deprecated Use {@link createTester} */
export async function createTestRunner(host?: TestHost): Promise<BasicTestRunner> {
const testHost = host ?? (await createTestHost());
return createTestWrapper(testHost);
Expand Down
7 changes: 6 additions & 1 deletion packages/compiler/src/testing/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ export function resolveVirtualPath(path: string, ...paths: string[]) {
return resolvePath(rootDir, path, ...paths);
}

/** Find the package root from the provided file */
/** Find the package root from the provided file
* @deprecated Use {@link createTester} instead
*/
export function findTestPackageRoot(fileUrl: string): Promise<string> {
return findProjectRoot(NodeHost.stat, fileURLToPath(fileUrl)) as Promise<string>;
}
/**
* Define a test library defaulting to the most common library structure.
* @param init Library configuration.
* @returns TypeSpec Test library.
* @deprecated Use {@link createTester} instead
*/
export function createTestLibrary(init: TypeSpecTestLibraryInit): TypeSpecTestLibrary {
const { name } = init;
Expand All @@ -53,6 +56,7 @@ export function createTestLibrary(init: TypeSpecTestLibraryInit): TypeSpecTestLi
};
}

/** @deprecated Use {@link Tester} instead */
export interface TestWrapperOptions {
wrapper?: (code: string) => string;

Expand All @@ -68,6 +72,7 @@ export interface TestWrapperOptions {

compilerOptions?: CompilerOptions;
}
/** @deprecated Use {@link createTester} instead */
export function createTestWrapper(
host: TestHost,
testWrapperOptions: TestWrapperOptions = {},
Expand Down
7 changes: 7 additions & 0 deletions packages/compiler/src/testing/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ export interface PositionedMarkerInFile extends PositionedMarker {
// #endregion

// #region Legacy Test host
/** @deprecated Use {@link Tester} */
export interface TestHost extends Pick<
TestFileSystem,
| "addTypeSpecFile"
Expand All @@ -243,12 +244,14 @@ export interface TestHost extends Pick<
): Promise<[Record<string, Type>, readonly Diagnostic[]]>;
}

/** @deprecated Use {@link Tester} */
export interface TestFiles {
realDir: string;
pattern: string;
virtualPath: string;
}

/** @deprecated Use {@link Tester} */
export interface TypeSpecTestLibraryInit {
name: string;
packageRoot: string;
Expand All @@ -263,16 +266,19 @@ export interface TypeSpecTestLibraryInit {
jsFileFolder?: string;
}

/** @deprecated Use {@link Tester} */
export interface TypeSpecTestLibrary {
name: string;
packageRoot: string;
files: TestFiles[];
}

/** @deprecated Use {@link Tester} */
export interface TestHostConfig {
libraries?: TypeSpecTestLibrary[];
}

/** @deprecated Use {@link Tester} */
export class TestHostError extends Error {
constructor(
message: string,
Expand All @@ -282,6 +288,7 @@ export class TestHostError extends Error {
}
}

/** @deprecated Use {@link TesterInstance} */
export interface BasicTestRunner {
readonly program: Program;
readonly fs: Map<string, string>;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

8 changes: 0 additions & 8 deletions packages/compiler/templates/scaffolding.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@
"path": "library-ts/src/rules/no-interfaces.rule.ts",
"destination": "src/rules/no-interfaces.rule.ts"
},
{
"path": "library-ts/src/testing/index.ts.mu",
"destination": "src/testing/index.ts"
},
{
"path": "library-ts/test/decorators.test.ts.mu",
"destination": "test/decorators.test.ts"
Expand Down Expand Up @@ -185,10 +181,6 @@
"path": "emitter-ts/src/lib.ts",
"destination": "src/lib.ts"
},
{
"path": "emitter-ts/src/testing/index.ts.mu",
"destination": "src/testing/index.ts"
},
{
"path": "emitter-ts/test/hello.test.ts",
"destination": "test/hello.test.ts"
Expand Down
1 change: 1 addition & 0 deletions packages/emitter-framework/src/testing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { resolvePath } from "@typespec/compiler";
import { createTestLibrary, type TypeSpecTestLibrary } from "@typespec/compiler/testing";
import { fileURLToPath } from "url";

/** @deprecated Use `createTester` from `@typespec/compiler/testing` instead */
export const EmitterFrameworkTestLibrary: TypeSpecTestLibrary = createTestLibrary({
name: "@typespec/emitter-framework",
packageRoot: resolvePath(fileURLToPath(import.meta.url), "../../../"),
Expand Down
1 change: 1 addition & 0 deletions packages/events/src/testing/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createTestLibrary, findTestPackageRoot } from "@typespec/compiler/testing";

/** @deprecated Use `createTester` from `@typespec/compiler/testing` instead */
export const EventsTestLibrary = createTestLibrary({
name: "@typespec/events",
packageRoot: await findTestPackageRoot(import.meta.url),
Expand Down
1 change: 1 addition & 0 deletions packages/html-program-viewer/src/testing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
type TypeSpecTestLibrary,
} from "@typespec/compiler/testing";

/** @deprecated Use `createTester` from `@typespec/compiler/testing` instead */
export const ProgramViewerTestLibrary: TypeSpecTestLibrary = createTestLibrary({
name: "@typespec/html-program-viewer",
jsFileFolder: "dist/emitter",
Expand Down
1 change: 1 addition & 0 deletions packages/http-client-js/src/testing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { resolvePath } from "@typespec/compiler";
import { createTestLibrary, TypeSpecTestLibrary } from "@typespec/compiler/testing";
import { fileURLToPath } from "url";

/** @deprecated Use `createTester` from `@typespec/compiler/testing` instead */
export const HttpClientJavascriptEmitterTestLibrary: TypeSpecTestLibrary = createTestLibrary({
name: "@typespec/http-client-js",
packageRoot: resolvePath(fileURLToPath(import.meta.url), "../../../"),
Expand Down
1 change: 1 addition & 0 deletions packages/http-client/src/testing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { resolvePath } from "@typespec/compiler";
import { createTestLibrary, TypeSpecTestLibrary } from "@typespec/compiler/testing";
import { fileURLToPath } from "url";

/** @deprecated Use `createTester` from `@typespec/compiler/testing` instead */
export const HttpClientTestLibrary: TypeSpecTestLibrary = createTestLibrary({
name: "@typespec/http-client",
packageRoot: resolvePath(fileURLToPath(import.meta.url), "../../../../"),
Expand Down
1 change: 1 addition & 0 deletions packages/http-server-js/src/testing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
findTestPackageRoot,
} from "@typespec/compiler/testing";

/** @deprecated Use `createTester` from `@typespec/compiler/testing` instead */
export const HttpServerJavaScriptTestLibrary: TypeSpecTestLibrary = createTestLibrary({
name: "@typespec/http-server-js",
packageRoot: await findTestPackageRoot(import.meta.url),
Expand Down
1 change: 1 addition & 0 deletions packages/http/src/testing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
TypeSpecTestLibrary,
} from "@typespec/compiler/testing";

/** @deprecated Use `createTester` from `@typespec/compiler/testing` instead */
export const HttpTestLibrary: TypeSpecTestLibrary = createTestLibrary({
name: "@typespec/http",
packageRoot: await findTestPackageRoot(import.meta.url),
Expand Down
1 change: 1 addition & 0 deletions packages/json-schema/src/testing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
type TypeSpecTestLibrary,
} from "@typespec/compiler/testing";

/** @deprecated Use `createTester` from `@typespec/compiler/testing` instead */
export const JsonSchemaTestLibrary: TypeSpecTestLibrary = createTestLibrary({
name: "@typespec/json-schema",
packageRoot: await findTestPackageRoot(import.meta.url),
Expand Down
1 change: 1 addition & 0 deletions packages/library-linter/src/testing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
TypeSpecTestLibrary,
} from "@typespec/compiler/testing";

/** @deprecated Use `createTester` from `@typespec/compiler/testing` instead */
export const LibraryLinterTestLibrary: TypeSpecTestLibrary = createTestLibrary({
name: "@typespec/library-linter",
packageRoot: await findTestPackageRoot(import.meta.url),
Expand Down
1 change: 1 addition & 0 deletions packages/rest/src/testing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
TypeSpecTestLibrary,
} from "@typespec/compiler/testing";

/** @deprecated Use `createTester` from `@typespec/compiler/testing` instead */
export const RestTestLibrary: TypeSpecTestLibrary = createTestLibrary({
name: "@typespec/rest",
packageRoot: await findTestPackageRoot(import.meta.url),
Expand Down
1 change: 1 addition & 0 deletions packages/sse/src/testing/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createTestLibrary, findTestPackageRoot } from "@typespec/compiler/testing";

/** @deprecated Use `createTester` from `@typespec/compiler/testing` instead */
export const SSETestLibrary = createTestLibrary({
name: "@typespec/sse",
packageRoot: await findTestPackageRoot(import.meta.url),
Expand Down
1 change: 1 addition & 0 deletions packages/streams/src/testing/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createTestLibrary, findTestPackageRoot } from "@typespec/compiler/testing";

/** @deprecated Use `createTester` from `@typespec/compiler/testing` instead */
export const StreamsTestLibrary = createTestLibrary({
name: "@typespec/streams",
packageRoot: await findTestPackageRoot(import.meta.url),
Expand Down
1 change: 1 addition & 0 deletions packages/versioning/src/testing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
type TypeSpecTestLibrary,
} from "@typespec/compiler/testing";

/** @deprecated Use `createTester` from `@typespec/compiler/testing` instead */
export const VersioningTestLibrary: TypeSpecTestLibrary = createTestLibrary({
name: "@typespec/versioning",
packageRoot: await findTestPackageRoot(import.meta.url),
Expand Down
1 change: 1 addition & 0 deletions packages/xml/src/testing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
type TypeSpecTestLibrary,
} from "@typespec/compiler/testing";

/** @deprecated Use `createTester` from `@typespec/compiler/testing` instead */
export const XmlTestLibrary: TypeSpecTestLibrary = createTestLibrary({
name: "@typespec/xml",
packageRoot: await findTestPackageRoot(import.meta.url),
Expand Down
Loading