App for collecting sleep log answers, connecting to the somnus main application.
This project is based on Ionic (with Cordova).
After setting up Ionic, run ionic serve
to launch the app on localhost for development.
In order to execute Karma/Jasmine (unit) tests, run npm test
.
Before running integration tests, make sure a non-critical instance of the back end Somnus application is running, reachable, and has appropriate test users (with appropriate rights) in place; check test-utils.ts for details.
Do not run integration tests against a production back end, since they alter data.
Integration tests can then be executed with npm test-integration
.
In order to build a production release, do ionic cordova build <platform> --release --prod
.
We currently don't use an automated releasing/versioning system, so bump versions manually and add a git tag.
The relevant fields are version
and android-versionCode
in config.xml
.
For some reason, cordova plugins are sometimes not properly installed, leading to faulty behavior.
Look out for errors during plugin installation (e.g. during ionic cordova platform add <platform>
).
Things that might help (each on its own, not necessarily in sequence):
ionic cordova platform remove <platform>
, then ionic cordova platform add <platform>
ionic cordova prepare
ionic cordova platform add android@8.1.0
, as otherwise an older one may be auto-selectedFor example, in some cases, the prod-built app on phones fails to make requests to the server; they fail with 404 (allegedly from cache).
This is caused by cordova-plugin-whitelist
not being properly installed.
Just re-add it and everything should work as expected.
Background info: https://forum.ionicframework.com/t/api-request-404-from-cache-on-android-device/110012/3
By default, Ionic generates resources during platform-add. Prevent this by adding the --no-resources
flag.
This might surface as a failing ionic build, npm install or node-sass rebuild. The error message contains something along the lines of:
Error:
make
failed with exit code: 2
And further up errors stemming from C++ code compilation (probably referring to v8).
This can be caused by API mismatches between v8 and node-sass, meaning that the versions of node and node-sass are not compatible. If the same build used to work before and/or on other machines, it probably had a different node version installed.
Transpilation fails with errors in @types/jasmine/index.d.ts
where error lines and columns don't quite seem to match actual code.
Error messages typically claim to miss some syntax elements, like ';', '(', or ']'.
Cause for this is likely a mismatch between node (or typescript?) and @types/jasmine versions. E.g. @types/jasmine 2.8.6 seems to work with node 10.x.
In the JavaScript console, an error is logged Uncaught Error: Cannot find module "."
.
It's not entirely clear how this happens, and there's a range of possible causes. In some cases, changing TypeScript version fixes the issue, as has been observed with 2.8.3 (working) vs. 2.8.4 (not working).