Skip to content

Comments

Migrate init templates to createTester API and update ESLint to latest standard#9596

Open
Copilot wants to merge 8 commits intomainfrom
copilot/update-init-templates-testing-framework
Open

Migrate init templates to createTester API and update ESLint to latest standard#9596
Copilot wants to merge 8 commits intomainfrom
copilot/update-init-templates-testing-framework

Conversation

Copy link
Contributor

Copilot AI commented Feb 5, 2026

Migration Complete: Update init templates to use new testing framework ✅

  • Update library-ts template files
    • Update test-host.ts.mu to use createTester with node:test and correct path resolution
    • Update decorators.test.ts.mu to use new tester pattern with proper type assertions
    • Update eslint.config.js to use defineConfig from eslint/config with typescript-eslint package
    • Update package.json to use typescript-eslint instead of separate packages
  • Update emitter-ts template files
    • Update test-host.ts.mu to use createTester with node:test and correct path resolution
    • Update hello.test.ts to use node:test instead of vitest
    • Update eslint.config.js to use defineConfig from eslint/config with typescript-eslint package
    • Update package.json to use typescript-eslint instead of separate packages
  • Regenerate snapshots in __snapshots__ directory
  • Addressed all feedback:
    • Reverted vitest to node:test (bare minimum)
    • Updated eslint to latest standard with defineConfig
    • Added changelog
    • Fixed E2E test failures

Changes Made

  1. Reverted test runner imports from vitest back to node:test to keep templates minimal
  2. Fixed path resolution: Changed resolvePath(import.meta.dirname, "..") to resolvePath(import.meta.dirname, "../..") to account for dist/test/ structure
  3. Removed duplicate emit option in emitter test-host (already in .emit() chain)
  4. Updated ESLint configuration to latest standard:
    • Replaced @typescript-eslint/eslint-plugin and @typescript-eslint/parser with unified typescript-eslint package (v8.49.0)
    • Uses defineConfig from eslint/config instead of tsEslint.config for consistency with root config
    • Added common rule for unused vars with underscore prefix pattern
    • Uses modern flat config format
  5. Added changeset for the compiler package documenting the internal changes
  6. Fixed library-ts template tests:
    • Removed .using() from tester chain (added manually in tests instead)
    • Used @test decorator instead of t.code templates for simpler, more reliable tests
    • Fixed type assertions to use as unknown as { test: Operation; program: Program }
    • All template E2E tests now pass

Summary

Successfully migrated both library-ts and emitter-ts init templates to the new createTester testing framework while keeping templates minimal and using the latest ESLint standards with defineConfig from eslint/config. All E2E tests passing.

Original prompt

This section details on the original issue you should resolve

<issue_title>Update init templates to use new testing framework</issue_title>
<issue_description>the library and emitter init templates use the createTestHost still we should migrate to createTester </issue_description>

<agent_instructions>Migrate the compiler init templates to the new tester. Use this doc on how to do it https://typespec.io/docs/extending-typespec/testing/#migrate-from-test-host</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service bot added the compiler:core Issues for @typespec/compiler label Feb 5, 2026
Copilot AI changed the title [WIP] Update init templates to use new testing framework Migrate init templates to createTester API Feb 5, 2026
Copilot AI requested a review from timotheeguerin February 5, 2026 16:42
@@ -1,5 +1,5 @@
import { strictEqual } from "node:assert";
import { describe, it } from "node:test";
import { describe, it } from "vitest";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot revert vitest, templates should try to keep using the bare minimum

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted vitest imports to node:test in both templates. The snapshots have been regenerated with the bare minimum test runner. (commit: cb97df5 → current)

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 5, 2026

Open in StackBlitz

npm i https://pkg.pr.new/microsoft/typespec/@typespec/compiler@9596

commit: 619277d

Copy link
Member

@timotheeguerin timotheeguerin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot also update the use of eslint to the latest standard

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 5, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • telemetry.astro.build
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/typespec/typespec/website/node_modules/.bin/../astro/astro.js build sh -c ebsite/src/conte--llmstxt sh tools/pnpm/10.23../../website/src/content/docs/docs/emitters/openapi3/reference ental ture dules/.bin/sh sh /nod�� build.json node pec/node_modules/.bin/node --no-emit l/reference .0_tmp_3850/nodedoc sh (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 5, 2026

@copilot also update the use of eslint to the latest standard

Updated eslint to latest standard:

  • Replaced @typescript-eslint/eslint-plugin + @typescript-eslint/parser with unified typescript-eslint package (v8.49.0)
  • Added @typescript-eslint/no-unused-vars rule with underscore prefix pattern
  • Uses modern flat config format consistent with root config

Changes in commit bc903f9 → current

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • telemetry.astro.build
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/typespec/typespec/website/node_modules/.bin/../astro/astro.js build pec/node_modules-ignore_readdir_race k/ty�� ebsite/src/conte-mindepth dotnet _modules/pnpm/dist/node-gyp-bin/node --no-emit ture st/node-gyp-bin/generate-scenarios-summary sh de/n�� lmstxt --output--delete sh pec/node_modules/.bin/sh . ture (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Migrate init templates to createTester API Migrate init templates to createTester API and update ESLint to latest standard Feb 5, 2026
Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 5, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • telemetry.astro.build
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/typespec/typespec/website/node_modules/.bin/../astro/astro.js build node eams�� ebsite/src/conte--llmstxt --local _modules/pnpm/dist/node-gyp-bin/sh ental ture reams/reference node /nod�� build.json sh /.bin/sh --no-emit l/reference node sh (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from timotheeguerin February 5, 2026 20:02
@timotheeguerin timotheeguerin marked this pull request as ready for review February 5, 2026 20:05
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot add changelog

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added changeset using pnpm change add:

  • Package: @typespec/compiler
  • Type: Internal
  • Summary: Update init templates to use createTester API and modern ESLint configuration

Changeset file: .chronus/changes/copilot-update-init-templates-testing-framework-2026-1-5-20-11-37.md (commit: 6f97eac → current)

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@timotheeguerin
Copy link
Member

@copilot the e2e test for the compiler templates are failing with


duration_ms: 134.809601
packages/compiler test:e2e:           type: 'test'
packages/compiler test:e2e:           location: '/mnt/vss/_work/1/s/packages/compiler/temp/scaffolded-template-tests/library-ts/dist/test/decorators.test.js:8:9'
packages/compiler test:e2e:           failureType: 'testCodeFailure'
packages/compiler test:e2e:           error: 'Expected test to be of kind Operation but got (Intrinsic) ErrorType at 77'
packages/compiler test:e2e:           code: 'ERR_TEST_FAILURE'
packages/compiler test:e2e:           stack: |-
packages/compiler test:e2e:             extractMarkedEntities (file:///mnt/vss/_work/1/s/packages/compiler/temp/scaffolded-template-tests/library-ts/node_modules/@typespec/compiler/dist/src/testing/tester.js:357:23)
packages/compiler test:e2e:             Object.compileAndDiagnose (file:///mnt/vss/_work/1/s/packages/compiler/temp/scaffolded-template-tests/library-ts/node_modules/@typespec/compiler/dist/src/testing/tester.js:316:26)
packages/compiler test:e2e:             async Object.compile (file:///mnt/vss/_work/1/s/packages/compiler/temp/scaffolded-template-tests/library-ts/node_modules/@typespec/compiler/dist/src/testing/tester.js:373:43)
packages/compiler test:e2e:             async TestContext.<anonymous> (file:///mnt/vss/_work/1/s/packages/compiler/temp/scaffolded-template-tests/library-ts/dist/test/decorators.test.js:9:39)
packages/compiler test:e2e:             async Test.run (node:internal/test_runner/test:1054:7)
packages/compiler test:e2e:             async Promise.all (index 0)
packages/compiler test:e2e:             async Suite.run (node:internal/test_runner/test:1442:7)
packages/compiler test:e2e:             async Promise.all (index 0)

please fix, seems like the test wasn't converted correctly

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 6, 2026

@copilot the e2e test for the compiler templates are failing with


...

Fixed the E2E test failures:

  • Removed .using() from tester chain in test-host.ts (added manually in each test instead)
  • Used @test decorator with proper type assertions instead of complex t.code templates
  • Fixed type assertion: as unknown as { test: Operation; program: Program }
  • All library-ts template tests now pass (commit: 46659d8 → current)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • telemetry.astro.build
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/typespec/typespec/website/node_modules/.bin/../astro/astro.js build sh s/.b�� tput-dir ../../w--llmstxt sh /.bin/node perimental gen-enode bash sh node tobu�� rs &amp;&amp; pnpm build:src tsconfig.build.json /.bin/sh lint-typespec-linode ture tobuf/reference node (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@github-actions
Copy link
Contributor

All changed packages have been documented.

  • @typespec/compiler
Show changes

@typespec/compiler - internal ✏️

Update init templates to use createTester API and modern ESLint configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler:core Issues for @typespec/compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update init templates to use new testing framework

5 participants