hbenl / vscode-jasmine-test-adapter

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

Tests with imports don't load #22

Closed peteringram0 closed 5 years ago

peteringram0 commented 5 years ago

Any .spec file that has a import does not show. If the imports are removed from the file it will show.

hbenl commented 5 years ago

Are you talking about ES6 imports? How do you run your tests when not using this adapter?

peteringram0 commented 5 years ago

Yes. via karma (im guessing thats the issue?)

hbenl commented 5 years ago

Yes, this adapter only works with tests that are run with Jasmine directly. There is a request for a Karma Test Adapter but since I don't use Karma myself, someone else would have to implement it.

raof01 commented 5 years ago

It seems that jasmine-es6 doesn't work with the explorer. I installed jasmine-es6 by using: $> sudo npm install -g jasmine-es6 --save-dev and then I created examples by using jasmine command: $> jasmine init $> jasmine examples Then I changed the Player.js and PlayerSpec.js to use export and import. unfortunately this doesn't work (from "Jasmine Explorer" in OUTPUT panel):

(function (exports, require, module, filename, dirname) { import { Player } from '../../lib/jasmine_examples/Player'; ^ SyntaxError: Unexpected token {

However, I can run jasmine via command line and get the correct results:

$> jasmine
Started .....

5 specs, 0 failures Finished in 0.056 seconds

How can I change configurations to make the explorer work?

hbenl commented 5 years ago

@raof01 This test adapter always uses the original jasmine (which is bundled with the extension), whereas when you call jasmine on the command line you'll get the modified version of jasmine from the jasmine-es6 package. That's why it works on the command line but not in the Test Explorer. If this is just about enabling es6 support (through babel), I'd suggest you find a way to do that with the original jasmine. For example, this repo uses babel and jasmine and works with this extension as soon as I tell it where it can find jasmine.json by adding "jasmineExplorer.config": "test/unit/jasmine.json" to the settings.

raof01 commented 5 years ago

Thanks for sharing the info. Now it works. Do you have any plan to support selection of es6 and es5, etc.? Or Karma adapter you mentioned above will consider this kind of choices of ECMAScript versions?

hbenl commented 5 years ago

This adapter only connects jasmine to the Test Explorer, it doesn't modify jasmine (nor do I plan to do that in the future). So you'd have to ask that question to the developers of jasmine, if they support it, so will this adapter.

raof01 commented 5 years ago

It's clear for me now. Thanks for your patience.