hbenl / vscode-jasmine-test-adapter

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

Configuration for angularjs projects #18

Closed francittadini closed 6 years ago

francittadini commented 6 years ago

I cannot get the proper configuration for my angularjs project. How do I import angular-mocks? Also, how do I tell the extension where are my sources?

Thanks!

hbenl commented 6 years ago

What do you do to run your tests on the command line?

francittadini commented 6 years ago

I'm using Chutzpah Test Runner in Visual Studio. I don't know if you are familiar with it, but you have one config where you setup your external libs (like angular-mocks or jasmine) and your source files. I'm trying to make everything work in VSCode.

hbenl commented 6 years ago

I'm not familiar with it but it's running the tests in PhantomJS, right? That would mean you can't simply convert your Chutzpah setup to a pure Jasmine setup and so it won't work with this adapter. A Chutzpah Test Adapter would be needed to do this.

francittadini commented 6 years ago

Yeah, that sounds logic. Thanks for your answers 😃

SylChamber commented 6 years ago

@francittadini

Actually, it is possible to run AngularJS in Node.js for more developer friendly testing, by using jsdom to simulate the browser. That's the technique being used for testing by the React.js and (it seems) the Vue.js communities.

However, test setup for AngularJS unit testing in Node is difficult, and references are difficult to find.

This summer, I finally succeeded in running tests using Jest and Cucumber.js, but I had difficulties with the Jasmine test adapter for VS Code. It was working when in debug, but not when running the tests.

Since I really like the Jest extension's "live testing" mode, I did not pursue my efforts with the Jasmine test explorer. But I would really like to make it work, because I really like it's test explorer.

I've been meaning to post an article on testing AngularJS with jsdom. Ping me after the weekend. Same handle on Twitter as on GitHub.

SylChamber commented 6 years ago

@francittadini Actually, I forgot I started before my vacation a project on Github to document and demonstrate how to test AngularJS using a Node.js based framework (in my case, Jest and Cucumber.js). It's just in the early stages, I want to write a guide and add JSDoc comments to the code, and I want to dig up all the obscure references that helped me figure it out in order to give credit. But the code should give you an idea how to configure Jasmine for Node.js to test AngularJS.

Start with command-line Jasmine. If you make it work, it should work with the Jasmine test explorer for VS Code.

hbenl commented 5 years ago

A Karma adapter is being worked on, see hbenl/vscode-example-test-adapter#1