-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jasmine-TS support #19
Comments
The adapter needs a communication channel through which Jasmine can report the results of loading or running the tests. The current communication channel would most likely not work with the CLI version of Jasmine or Jasmine-TS, so currently I can only recommend to use Jasmine and node-ts directly. |
Is it possible to pass node arguments in adapter config? as options of this child process vscode-jasmine-test-adapter/src/adapter.ts Line 118 in 7191fff
So, we'll be able to use node --require ts-node/register |
Well I spoke too soon. It worked on a small test project with a tsconfig.json file set to:
However, my Angular CLI project uses:
When I switch to es2015, I get the following error: (function (exports, require, module, __filename, __dirname) { import { async, TestBed } from '@angular/core/testing';
^^^^^^
SyntaxError: Unexpected token import Although no module resolution error is visible, I believe it is because it cannot resolve the location of the required ts-node module that is sent to Node as an arg:
It finds ts-node when installed locally in the small test project. It also finds it in the Angular CLI project when I change "module" to "commonjs" in the tsconfig.json file. I am not sure how to correct this. |
@johnhamm I spent some time yesterday trying out your PR and ran into that myself. See https://stackoverflow.com/questions/40635956/overriding-tsconfig-json-for-ts-node-in-mocha for some options for solving it. I solved it by creating a second tsconfig.json with module: commonjs, but the TS_NODE_COMPILER_OPTIONS environment variable solution looks potentially even better. |
Unfortunately adding that jasminExplorer.env setting did not change the error (ts-node doesn't seem to be using that env variable for some reason), but directly changing "module" to "commonjs" in the project's ./tsconfig.json file does, but then I get errors where it can no longer find my modules that use a relative path (I use baseUrl in my tsconfig.json file so I don't have to do '../../app/core/models/id' etc:
|
@johnhamm perhaps the tsconfig-paths package can help? We use it like this on the CLI:
|
@jelling - that did the trick! Thank you so much. So to recap for anyone experiencing this in the future:
"jasmineExplorer.nodeArgv": [
"--require",
"ts-node/register",
"--require",
"tsconfig-paths/register"
],
"jasmineExplorer.env": {
"TS_NODE_COMPILER_OPTIONS": "{\"module\":\"commonjs\"}"
}, You will need the ts-node and tsconfig-paths NPM packages installed in your project. |
@johnhamm I'm glad someone has this working! Perhaps a dumb question, but is there anything else needed? I installed those packages and of course have the plugin installed, but it is unable to find any of my tests. We don't have them all in one directory, but rather they're bundled in separate directories with each angular component we make. We're on Angular 6+ using jasmine and karma. Any other tips you could provide would be immensely helpful, thank you! |
@supersinex This adapter can't load and run Karma tests, but a Karma adapter is being worked on, see hbenl/vscode-example-test-adapter#1 |
Thanks for linking that, @hbenl! That looks super promising 👍 |
Sorry but I can't get working I have spec in src/specs/module/test.e2e-spec.ts I added the ts-node and tsconfig-paths and I added in the user and workspace the settings "jasmineExplorer.nodeArgv": [ |
@apis3445 Can you point me to a sample project with which I can reproduce this? |
it is a normal angular + protractor, maybe is due to protractor with the latest version of annual |
So are these tests karma or protractor tests? In that case, it won't work with this adapter, but for Karma tests there is the Angular/Karma Test adapter. |
yes it is protractor test cases |
We use Jasmine-TS to run our tests as it saves a compilation step and solves a few other problems for us. Naturally, jasmine-test-adapter extension just uses jasmine directly.
Could support be added for Jasmine-TS? I looked at the source for the extension and it's using Jasmine programmatically, as opposed to calling the CLI version of Jasmine. Jasmine-TS doesn't seem to have that feature but I don't know how much that matters.
The text was updated successfully, but these errors were encountered: