hbenl / vscode-jasmine-test-adapter

Jasmine Test Adapter for the VS Code Test Explorer
MIT License
20 stars 20 forks source link

Jasmine tests not displaying #38

Open SEISENREICH1 opened 4 years ago

SEISENREICH1 commented 4 years ago

Hello! I am trying to get the Jasmine explorer working with my project, but it is not displaying any of the tests. I think I found the reason, but I am not positive.

  1. My project is setup with the workspace directory as "c:\Source\Master\App"
  2. The tests are located in "c:\Source\Master\App\AppSFSvc\ClientApp\e2e\tests"

below is the output of the log file I configured ("jasmineExplorer.logfile":"C:\temp\jasminelog.txt",).

the specific line I am looking at is "Creating adapter for c:\Source\Master\App". Looking into adapter.ts I see it is using the vscode workspace dir "public readonly workspaceFolder: vscode.WorkspaceFolder"

Assuming this is the problem (it may not be), is there a way to overwrite this in the config?

[2020-01-16 11:09:35.001] [INFO] Test Explorer found [2020-01-16 11:09:35.001] [INFO] Creating adapter for c:\Source\Master\App [2020-01-16 11:09:35.001] [INFO] Registering adapter for c:\Source\Master\App [2020-01-16 11:09:35.002] [DEBUG] Using config file: c:\Source\Master\App\AppSFSvc\ClientApp\e2e\tsconfig.e2e.json [2020-01-16 11:09:35.002] [INFO] Initialization finished

Thanks,

Scott

hbenl commented 4 years ago

[2020-01-16 11:09:35.002] [DEBUG] Using config file: c:\Source\Master\App\AppSFSvc\ClientApp\e2e\tsconfig.e2e.json

It looks like you set jasmineExplorer.config to point to your Typescript configuration instead of your Jasmine configuration (usually called jasmine.json).

SEISENREICH1 commented 4 years ago

I changed it to jasmine.json. I got further, but now I cannot seem to change the "specDir" property. I downloaded the code and tried to change it there, but it does not seem to change no matter what I do even if I hard-code the directory. In adapter.js I have tried all of the following, but still get the same specDir: const specDir = vscode.env.appRoot; const specDir = vscode.workspace.asRelativePath.name; const specDir = vscode.workspace.getWorkspaceFolder.toString(); const specDir = "C:/Source/////e2e/src/tests"

Here is the log output:

[2020-01-27 13:59:37.769] [DEBUG] Using config file: C:\Users\eisenreichsr\AppData\Local\Programs\Microsoft VS Code\jasmine.json [2020-01-27 13:59:37.770] [INFO] Initialization finished [2020-01-27 13:59:37.808] [DEBUG] Using specDir: C:\Users\eisenreichsr\AppData\Local\Programs\Microsoft VS Code\specs [2020-01-27 13:59:37.808] [DEBUG] Using test file glob: C:\Users\eisenreichsr\AppData\Local\Programs\Microsoft VS Code\specs*\[sS]pec.js [2020-01-27 13:59:37.810] [DEBUG] Using environment variable config: {"TS_NODE_COMPILER_OPTIONS":"{\"module\":\"commonjs\"}"} [2020-01-27 13:59:37.810] [DEBUG] Using nodePath: undefined [2020-01-27 13:59:37.810] [DEBUG] Using node arguments: --require,ts-node/register,--require,tsconfig-paths/register [2020-01-27 13:59:37.812] [DEBUG] Using breakOnFirstLine: false [2020-01-27 13:59:37.812] [INFO] Loading test files of [2020-01-27 13:59:38.163] [INFO] Worker finished [2020-01-27 13:59:50.045] [INFO] Loading test files of [2020-01-27 13:59:50.194] [INFO] Worker finished

hbenl commented 4 years ago

Now it seems that jasmineExplorer.config points to a file in VS Code's data folder, not in your workspace. The reason why changing the code of the extension didn't work for you may be that installing an extension from a *.vsix file is unreliable in VS Code: you have to uninstall the Marketplace version of the extension first and remove the files of that extension manually from where VS Code stores them (~/.vscode/extensions/ on Linux, not sure where they're stored on Windows) - otherwise VS Code may keep using the Marketplace version of the extension even after you installed your local version.

nbilyk commented 5 months ago

I had a similar issue (not sure if it's exactly the same) where jasmine tests were not correctly displaying. I would get a random sub-set of the tests instead of the full tree.

I fixed a local version of this, but I'm afraid I am at least a month away from having the bandwidth to put together a formal CR. I ended up changing many things around the load hierarchy.

The core of the bug in case this helps anybody is that the child process for the loadTestsReporter is terminated by jasmine before the reporting finishes. To fix this, change the done callback provided to the reporter to return a Promise that resolves when the message transfers finish, then add a jasmineDone method that calls the jasmineDone 'done' callback when the message transfer is complete.