Hi, i’m digging into tesing ionic 2 apps, i have a simple issue, idk nothing about testing js code, i have used rspec for ruby but in js i have read that karma + jasmine + phantomjs.
How is or will be the testing environment for ionic 2? do we have to set the testing environment ourselves?
Where should i place the spec dir or how should i test ionic 2 code?
Most of testing in the angular2 web site uses es6, but it could be needed to transpile it before runing tests, i think i will need to use the babel loader to transpile it, but idk how should i change it nor how to start it as ionic uses the serve cli command, and setting another build system for just the test is not worth it.
I haven’t seen a great testing guide on the subject. Angular 2’s looks like it is getting there, but is incomplete currently. I would suggest taking a look at this. It is the most complete example I’ve seen which includes a testing framework.
I looked at it, but I am a new to web development and testing. I think I need something easier to work with Ionic 2. Maybe, a simple working sample?
My concerns about how to configure the ionic project to run the tests?
The thing is that it has a lot of dependencies but lacks explanation about why you need each one or how do they glue together, i don’t like using something just because it works, i like to know how it does work just in case an error arise be able to debug.
The build kit for ionic 2 is already very complicated. The sample provided is using a very similar kit, and is fairly well documented in terms of commenting.
More to the point though, the angular docs are almost entirely missing for testing, and this provides at least a fair ammount of samples you could use. If it isn’t to your liking you can try this excellent video by Julie Ralph from NgConf - https://www.youtube.com/watch?v=C0F2E-PRm44
The syntax success website does a fair job of covering injection, but neither article covers how to handle unit testing directives. While it is fair to argue that they do not normally need to be tested, there are definitely occasions where you should.
We had a lot of trouble getting a testing framework up, largely due to the lack of documentation. I suppose that’s one of the troubles with alpha/beta release products. Hope this stuff at least helps in pointing you in the right direction.
Guys, I know you want to help, but I am too damn n00b to understand that bunch of configs in the webpack repo or in the julie repo and migrate to ionic.
If someone could make available an ionic v2 repo with working configs, a sample and the command to run the tests, it would be great.
@swarner answer referencing the angular2-webpack-starter is good, you could just copy and paste the configs into Ionic and start writing the tests with the examples in that repo, i would just like to understand how that webpack.test.config.js was made.
be sure to change the package.json and set the dependencies to the exact version (remove the ^ from the version), otherwise npm install will complain about unmet dependancies
Thanks for your tutorial, @lathonez. I’m going through it, trying to add testing to a new ionic (beta3) app.
I get to the “Install Dependencies and Typings” section and run the command “node_modules/gulp/bin/gulp.js --gulpfile test/gulpfile.ts --cwd ./ test.build”.
But the following errors happen (note: this is a clean install of the “blank” template). Any suggestions?
Good news. If there’s anything else, raise an issue on my repo rather than here. I just don’t want to clog up Ionic forums with problems particular to our setup.