Running Unit Tests
~~~~~~~~~~~~~~~~~~
+Create ``unit-test-configuration.ts`` file based on
+``unit-test-configuration.ts.sample`` in directory
+``src/pybind/mgr/dashboard/frontend/src``.
+
Run ``npm run test`` to execute the unit tests via `Jest
<https://facebook.github.io/jest/>`_.
--- /dev/null
+import { async, TestBed } from '@angular/core/testing';
+
+import { _DEV_ } from '../../unit-test-configuration';
+
+export function configureTestBed(configuration, useOldMethod?) {
+ if (_DEV_ && !useOldMethod) {
+ const resetTestingModule = TestBed.resetTestingModule;
+ beforeAll((done) =>
+ (async () => {
+ TestBed.resetTestingModule();
+ TestBed.configureTestingModule(configuration);
+ // prevent Angular from resetting testing module
+ TestBed.resetTestingModule = () => TestBed;
+ })()
+ .then(done)
+ .catch(done.fail));
+ afterAll(() => {
+ TestBed.resetTestingModule = resetTestingModule;
+ });
+ } else {
+ beforeEach(async(() => {
+ TestBed.configureTestingModule(configuration);
+ }));
+ }
+}
cd $CEPH_ROOT/src/pybind/mgr/dashboard/frontend
+config='src/unit-test-configuration.ts'
+if [ -e $config ]; then
+ mv $config ${config}_old
+fi
+cp ${config}.sample $config
+
. $CEPH_ROOT/build/src/pybind/mgr/dashboard/node-env/bin/activate
npm run build -- --prod
npm run test:ci
npm run lint
+rm $config
+if [ -e ${config}_old ]; then
+ mv ${config}_old $config
+fi
+
deactivate