Conversation
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Fixed in commit 4dd3c84. The issue was that the webpack Now when tests are built via webpack, the TypeScript checker uses the appropriate configuration that includes test files. TypeScript compile errors from test files now surface correctly during Tested with deliberate TypeScript errors in test files - they are now properly reported during webpack compilation. |
alexr00
left a comment
There was a problem hiding this comment.
Good start, but I also want the tests to compile into *.test.js files.
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Fixed in commit c089c26. The webpack configuration now generates individual Changes made:
Result:
The test infrastructure can now find and load individual test files as expected. |
alexr00
left a comment
There was a problem hiding this comment.
@copilot Seems like mocha is missing from the webpacked tests:
TypeError: Cannot read properties of undefined (reading 'describe')
at exports.describe (c:\Users\alros\repos\Microsoft\vscode-pull-request-github\node_modules\mocha\lib\mocha.js:112:26)
at c:\Users\alros\repos\Microsoft\vscode-pull-request-github\dist\test\github\markdownUtils.test.js:62750:48
at c:\Users\alros\repos\Microsoft\vscode-pull-request-github\dist\test\github\markdownUtils.test.js:62778:3
at Object.<anonymous> (c:\Users\alros\repos\Microsoft\vscode-pull-request-github\dist\test\github\markdownUtils.test.js:62781:12)
at Module._compile (node:internal/modules/cjs/loader:1696:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1829:10)
at Module.load (node:internal/modules/cjs/loader:1430:32)
at Module._load (node:internal/modules/cjs/loader:1253:12)
at c._load (node:electron/js2c/node_init:2:17993)
at e._load (file:///c:/Users/alros/repos/Microsoft/vscode-pull-request-github/.vscode-test/vscode-win32-x64-archive-insiders/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:393:5984)
at t._load (file:///c:/Users/alros/repos/Microsoft/vscode-pull-request-github/.vscode-test/vscode-win32-x64-archive-insiders/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:211:22649)
at r._load (file:///c:/Users/alros/repos/Microsoft/vscode-pull-request-github/.vscode-test/vscode-win32-x64-archive-insiders/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:203:25658)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:242:24)
at Module.require (node:internal/modules/cjs/loader:1452:12)
at require (node:internal/modules/helpers:135:16)
at c:\Users\alros\repos\Microsoft\vscode-pull-request-github\node_modules\@vscode\test-cli\node_modules\mocha\lib\mocha.js:396:36
at Array.forEach (<anonymous>)
at Mocha.loadFiles (c:\Users\alros\repos\Microsoft\vscode-pull-request-github\node_modules\@vscode\test-cli\node_modules\mocha\lib\mocha.js:393:14)
at Mocha.run (c:\Users\alros\repos\Microsoft\vscode-pull-request-github\node_modules\@vscode\test-cli\node_modules\mocha\lib\mocha.js:960:10)
at mochaGlobalTeardown.mochaGlobalTeardown (c:\Users\alros\repos\Microsoft\vscode-pull-request-github\node_modules\@vscode\test-cli\out\runner.cjs:33:50)
at new Promise (<anonymous>)
at Object.run (c:\Users\alros\repos\Microsoft\vscode-pull-request-github\node_modules\@vscode\test-cli\out\runner.cjs:33:11)
at file:///c:/Users/alros/repos/Microsoft/vscode-pull-request-github/.vscode-test/vscode-win32-x64-archive-insiders/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:118:17890
at new Promise (<anonymous>)
at pZ.sb (file:///c:/Users/alros/repos/Microsoft/vscode-pull-request-github/.vscode-test/vscode-win32-x64-archive-insiders/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:118:17611)
at async pZ.$extensionTestsExecute (file:///c:/Users/alros/repos/Microsoft/vscode-pull-request-github/.vscode-test/vscode-win32-x64-archive-insiders/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:118:17199)
[main 2025-09-26T15:52:58.483Z] Extension host with pid 35228 exited with code: 0, signal: unknown.
Exit code: 1
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Fixed in commit 7d50c90. The issue was that test fixtures were not being copied to the dist directory during webpack builds. Root cause: Tests depend on fixture files at Solution: Modified the build scripts to automatically copy fixtures after webpack compilation:
The webpack-compiled tests now have access to all required fixture files. |
…watch Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Fixed in commit fac13c5. Updated the Change made:
Watch mode now properly supports development workflows with test fixtures available from startup. |
…fixture copying Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Yes, absolutely! Fixed in commit 37d3106. Replaced the external preprocess-fixtures script with a custom webpack plugin. Changes made:
Benefits:
The webpack plugin replicates the exact behavior of the preprocess-fixtures script but integrates directly into the build process. |
Fix: Include tests in webpack compilation as individual *.test.js files with TypeScript checking, test fixtures, and watch mode support ✅ COMPLETED
Problem Statement:
Currently, tests are not compiled when the extension is built via webpack. Tests are compiled separately using TypeScript compiler (
tsc) viatsconfig.test.json, but they are not included in the main webpack build process.Analysis:
test/indexentry point)extensionentry point, missing testssrc/test/index.ts) expects compiled.jstest files in the test rootcompile:testusestscto compile tests toout/directory✅ Changes Made:
*.test.jsfiles for each test source filesrc/test/**/*.test.tsfiles and creates webpack entriesglobapproach for individual filesglob('**/**.test.js')to find individual test files (as expected by test infrastructure)require.contextbundling approachmarkdownUtils.test.tsto use globaldescribe/itfunctions instead of importing from 'mocha'Cannot read properties of undefined (reading 'describe')runtime errorCopyFixturesPluginto webpack configuration for node target onlyfixturesdirectories fromsrc/todist/after compilationpreprocess-fixturesscript calls from all build scriptscompile,compile:node,bundle,bundle:node, andwatchscriptsdist/test/*.test.js(23 individual test files) +dist/test/index.js(test runner) + fixtures - NEWdist/browser/test/index.js(bundled, existing)✅ Result:
✅ SOLVED: Tests are now compiled when the extension is built via webpack
✅ Individual
*.test.jsfiles: Node target creates separate files (not bundled)✅ TypeScript compile errors from tests now surface during webpack builds
✅ Mocha compatibility: Test files work correctly with Mocha's test runner environment
✅ Integrated fixture copying: Webpack plugin automatically copies fixtures without external scripts
✅ Watch mode support: Fixtures copied automatically during watch rebuilds
✅ Cleaner build process: No external script dependencies for fixture copying
✅ Maintains compatibility with existing test infrastructure that expects individual files
✅ No breaking changes to test execution workflow
✅ Follows project code style and copyright requirements
Addressing feedback:
✅ TypeScript compile errors from test files surface during webpack compilation
✅ Tests compile into individual
*.test.jsfiles (not bundled into single file)✅ Individual test files now work correctly with Mocha's global functions (
describe,it)✅ Test fixtures are automatically copied via webpack plugin (no external scripts)
✅ Watch mode properly handles test fixtures automatically
✅ Test infrastructure can find and load individual test files as expected
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.