You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to develop tests in a different directory/repository than the extension source code. This is to foster a separation of the test code from the functional code and to make it easier for other teams to get involved in writing tests.
I'm struggling to do this separation because all of the examples I found assume that the tests are in the same root directory as the extension source code.
I notice you're trying to import helloworld-sample/src/extension -- but this would try to import the source typescript file, not the compiled extension file. I don't think tsc will automatically change the import path when compiling in a workspace (you can verify by looking at your compiled files) so you may want to try helloworld-sample/out/extension instead.
Ah indeed. Changing the import to helloworld-sample/out/extension worked. Thanks!
I also had to add "declaration": true in the tsconfig.json of the extension workspace to produce a TS declaration file under out/ that allows me to make the above import.
Would you like me to cleanup the example and submit it in a PR? I realize that I moved the tests to a separate workspace. Instead I could keep the original workspace as is, and add new sample tests in the separate workspace.
Hello folks,
I would like to develop tests in a different directory/repository than the extension source code. This is to foster a separation of the test code from the functional code and to make it easier for other teams to get involved in writing tests.
I'm struggling to do this separation because all of the examples I found assume that the tests are in the same root directory as the extension source code.
I tried implementing the separation on a fork of the
helloworld-test-cli-sample
.I created a separate directory with its own
package.json
andtsconfig.json
and.vscode-test.mjs
.I used the
"workspaces"
feature inpackage.json
to allow the test code to import modules from the extension as follows:and I used
extensionDevelopmentPath
in.vscode-test.mjs
to let vscode-test know where the extension is.This allowed me to compile the tests successfully, and test execution is able to load the extension.
However the execution stumbles on the import line in the compiled JS test file:
Indeed the JS file has the following module import that can't be resolved:
I tried reading various documentations about module resolution but I can't figure out what I should do.
Should I somehow get
tsc
to emit a resolvedrequire
statement with the actual path to the compiled extension?Or should I somehow tell the test run-time environment how to resolve the
helloworld-sample
package based on thepackage.json
workspaces?I would appreciate any advice on the matter.
Thanks!
The text was updated successfully, but these errors were encountered: