Bram's Dev Blog

home

100 Days of Code Day 63 - Jasmine Testing

26 Oct 2018

DAY STILL IN PROGRESS

Want to finish this tonight, the content below is still rather messy.

DSpace 7 Testing

Tests are mandatory for contributions to DSpace 7 and my language switch pull request. Looked at a few spec.ts files in DSpace 7 to get a feel for it and found the Jasmine Tutorial to get going with this.

Karma vs Jasmine

Both Karma and Jasmine are being used, and it seems like Karma is a test runner, while Jasmine is the actual semantics for writing the unit tests.

https://karma-runner.github.io/3.0/intro/installation.html

Executing tests

Every time a pull request comes in to DSpace 7, the tests are automatically executed on Github.

To execute the tests you can execute npm test in the source root of the project.

Note that Angular CLI applications allow you to spin up the tests with “ng test” from the CLI. Because the DSpace 7 Angular UI is not (yet) compatible with Angular CLI, this currently does not work.

What is Karma?

Measuring Coverage

The DSpace 7 Angular build is integrated with Coveralls, that is able to measure whether test coverage of the code improves or decreases with a certain pull request. Inside the Github interface, a percentage summary is presented, showing how much coverage improved or decreased with the pull request. A detail page is available on coveralls that gives you more details.

In my example, coverage decreased because I added code without tests. However, I’m confused by the detail page on coveralls, as it seems to show changes in coverage for so many files and places that I didn’t touch.

First of all, I don’t know what the build compares to. The latest master? There might be changes on the latest master that I should rebase my own branch to.

Day 64 Plan

Write tests for my language switch pull request.

Future days - DSpace 7 Angular

Future days - Analyzer.atmire.com work

Future Days - Productivity

Future days - Jekyll http://bram-atmire.github.io/ site

Future Days - Atmire.com work

Investigate and work on search engine optimization (SEO) for the main atmire.com website.

Future Days - Learning just for learning

Sustainability challenge - Finish before Christmas

If I continue like October, I could hit day 68 by end of October and day 98 by end of November.