istanbul + mocha runs but stalls before the first test- why?


istanbul + mocha runs but stalls before the first test- why?
I have a large set of regression tests for the backend server.
Those tests no longer run to completion an fail at the first test.
This project grew out of the angular-starter project being built with webpack. The project runs well, but the regression tests not longer function.
The test in the server is run using (testServer.sh):
#!/usr/bin/env bash
find . -name "*.js" -type f -delete
rm -rf coverage
tsc
export NODE_ENV='test'
export ...
...
istanbul cover --config='test.istanbul.yml' --report html _mocha -- -- $(find . -path ../node_modules -prune -o -name '*.spec.js');
../node_modules/.bin/remap-istanbul -i coverage/coverage.json -o coverage-final -t html;
echo 'all done:'
find . -path ../node_modules -prune -o -name '*.spec.js' lists:
./api/user/user.controller.spec.js
./api/user/user.model.spec.js
./api/user/index.spec.js
...
...
./auth/local/local.spec.js
./email/email.spec.js
where the first test set comes from './api/user/user.controller.spec.js'.
This first test (user.controller.spec.ts) is:
import * as chai from 'chai';
import * as sinonChai from 'sinon-chai';
import log, error from '../../logging';
import mocha from 'mocha';
import * as app from '../../app';
import Token from '../user/token';
import * as userController from './user.controller';
import * as auth from '../../auth/auth.service';
import * as mongodb from 'mongodb';
import User from '../../api/user';
import UserData from '../../api/user';
chai.use(sinonChai);
const expect = chai.expect;
import * as request from 'supertest';
const users = User.getUsers();
describe('user.controller test', function ()
const admin_id = new mongodb.ObjectID('55148df6935c4bac084b30b2'); // JoelParke
const user_id = new mongodb.ObjectID('580bc41993b35207fd6c2263'); // joel@dynazu
const textangular_id = new mongodb.ObjectID('55a1baa2521bc91832f2450a');
const sample_id = new mongodb.ObjectID('5547e7520845397b4ff2eb18');
const icalAdmin = 'ZzO1xCPTB14qJrknRIXAkvRtWIqBewbEiH6dipFF.ics?nocache';
let accessTokenAdminUser: string;
this.timeout(10000);
before( (done: mocha.Done) =>
log('app setup');
app.start().then((res) =>
log('all setup and ready to test');
done();
);
);
it('checkSharingFromUsers success', (done: mocha.Done) =>
users.findOne(_id: admin_id)
.catch((err2: any) =>
throw err2;
)
.then((__user: UserData) =>
userController.checkSharingFrom(__user, textangular_id)
.then((result) =>
expect(result.found).equals(result.bWrite).equals(true);
done();
);
);
);
it('... success', (done: mocha.Done) => ... );
....
....
);
Running ./testServer.sh gives output from the call to app.start():
2018-07-29T13:52:01-0600 <log> app.js:9 () ApiSocket.bEnableSocket: set FALSE====================
*************** IPv6 array of addresses: [ '2601:283:8101:7c9e:e10a:a995:9c8f:ae87',
'2601:283:8101:7c9e:c73a:d0a6:5899:6e11' ]
(node:6535) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option useNewUrlParser: true to MongoClient.connect.
2018-07-29T13:52:01-0600 <log> seed.js:9 () removed 6 users
...
2018-07-29T13:52:01-0600 <log> seed.js:9 () populated 6 users.
2018-07-29T13:52:01-0600 <log> seed.js:9 () _users: 6
2018-07-29T13:52:01-0600 <log> seed.js:9 () removed 65 lists
2018-07-29T13:52:01-0600 <log> seed.js:9 () populated 65 lists.
2018-07-29T13:52:01-0600 <log> seed.js:9 () removed 881 tasks
2018-07-29T13:52:01-0600 <log> seed.js:9 () populated 881 tasks.
2018-07-29T13:52:01-0600 <log> seed.js:9 (Timeout._onTimeout) removed 1 commands
2018-07-29T13:52:01-0600 <log> seed.js:9 (Timeout._onTimeout) removed 10 files
2018-07-29T13:52:01-0600 <log> seed.js:9 () populated 10 files.
2018-07-29T13:52:01-0600 <log> seed.js:9 () removed 15 backups
2018-07-29T13:52:01-0600 <log> seed.js:9 () populated 15 backups.
2018-07-29T13:52:01-0600 <log> seed.js:9 () resolveAll ==============================
2018-07-29T13:52:01-0600 <log> app.js:9 () .............do transform.......
2018-07-29T13:52:01-0600 <log> transform.js:668 () done commands... 5
2018-07-29T13:52:01-0600 <log> transform.js:698 () done backups... 4
2018-07-29T13:52:01-0600 <log> transform.js:272 () done lists... 3
2018-07-29T13:52:01-0600 <log> transform.js:638 () done files... 2
2018-07-29T13:52:01-0600 <log> transform.js:874 () done users... 1
2018-07-29T13:52:01-0600 <log> transform.js:550 () done tasks... 0
2018-07-29T13:52:01-0600 <log> app.js:9 () ApiSocket.bEnableSocket: set TRUE ============================
2018-07-29T13:52:01-0600 <log> app.js:9 () *************** TEST SERVER ***************
BUT - I never see any log messages beyond the initial ones generated by the server starting up in app()
Setting verbose:true in test.istanbul.yml and running ./testServer.sh gives:
Using configuration
-------------------
verbose: true
instrumentation:
root: .
extensions:
- .js
default-excludes: true
excludes:
- '**/customError.*'
- '**/errors/*.*'
- '**/config/socketio.*'
- '**/transform.*'
- '**/*.spec.*'
- '**/*.ts'
embed-source: false
variable: __coverage__
compact: true
preserve-comments: false
complete-copy: false
save-baseline: false
baseline-file: ./coverage/coverage-baseline.json
include-all-sources: false
include-pid: false
es-modules: false
preload-sources: false
reporting:
print: summary
reports:
- html
dir: ./coverage
watermarks:
statements: [50, 80]
lines: [50, 80]
functions: [50, 80]
branches: [50, 80]
report-config:
clover: file: clover.xml
cobertura: file: cobertura-coverage.xml
json: file: coverage-final.json
json-summary: file: coverage-summary.json
lcovonly: file: lcov.info
teamcity: file: null, blockName: Code Coverage Summary
text: file: null, maxCols: 0
text-lcov: file: lcov.info
text-summary: file: null
hooks:
hook-run-in-context: false
post-require-hook: null
handle-sigint: true
check:
global:
statements: 0
lines: 0
branches: 0
functions: 0
excludes:
each:
statements: 0
lines: 0
branches: 0
functions: 0
excludes:
-------------------
Running: node /usr/local/bin/_mocha -- ./api/user/user.controller.spec.js ./api/user/user.model.spec.js ./api/user/index.spec.js ... ... ./email/email.spec.js
Module load hook: transform [/home/joel/workspace/Tracker3/server/logging.js]
Module load hook: transform [/home/joel/workspace/Tracker3/server/email/email.js]
Module load hook: transform [/home/joel/workspace/Tracker3/server/localEnv.js]
Module load hook: ... ... ...
Module load hook: ... ... ...
Module load hook: transform [/home/joel/workspace/Tracker3/server/auth/google/index.js]
Module load hook: transform [/home/joel/workspace/Tracker3/server/auth/gitlab/index.js]
This output is followed by the log messages from my server as it is instantiated (as shown above).
But I never see any other messages. After waiting a longtime, and hitting a ^C gives:
(because I have enabled handle-sigint: true in test.istanbul.yml)
^C=============================================================================
Writing coverage object [/home/joel/workspace/Tracker3/server/coverage/coverage.json]
Writing coverage reports at [/home/joel/workspace/Tracker3/server/coverage]
=============================================================================
=============================== Coverage summary ===============================
Statements : 54.15% ( 3643/6727 ), 1663 ignored
Branches : 56.19% ( 989/1760 ), 818 ignored
Functions : 35.07% ( 498/1420 ), 296 ignored
Lines : 54.15% ( 3641/6724 )
================================================================================
all done:
So for some reason the test is hanging. But it is unclear to me why this is, or how to debug this.
If you have any insight it would be greatly appreciated!!
NOTE: I have checked that the server is listening on the assigned port: 9000 as expected:
tcp6 0 0 :::9000 :::* LISTEN 1088/node
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Comments
Post a Comment