You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
seems to assume that Express started before the unit tests invoked by the Gulp task "mocha:unit" finish. In my case, the tests finished too early so I got:
1) "after all" hook:
TypeError: Cannot read property 'on' of undefined
at Context.<anonymous> (mocha.global.js:9:10)
The function startServer in app.js didn't complete in time so app.angularFullstack was undefined.
I worked around it but was wondering if anyone else ran into this.
The text was updated successfully, but these errors were encountered:
Sorry for the long delay in my reply. What I did was modify startServer() in app.js to this:
function startServer() {
app.shy = server.listen(config.port, config.ip, () => {
console.log(`Express listening on port ${config.port}, env = ${app.get('env')}`);
app.emit('appStarted'); // So mocha.global.js doesn't try to complete after all until Express starts
});
}
Here are the contents of my mocha.global.js:
/* global after */
import app from './';
after(function(done) {
// Unit tests are completing before /server/app.js:25 is executed causing an error
// Set the close handler after app.shy starts
app.on('appStarted', () => {
app.shy.on('close', () => done());
app.shy.close();
});
});
While this workaround is effective, I think the issue is with angular-fullstack not adding the done() callback to generated unit tests. See this posting on StackOverflow.
I'm guessing that you had angular-fullstack scaffold out an authentication boilerplate for you. If so, can you try renaming the user.model.spec.js file to something like user.model.disabled.js then re-run gulp test? I'm going to log a separate issue for that particular unit test.
The generated mocha.global.js:
seems to assume that Express started before the unit tests invoked by the Gulp task "mocha:unit" finish. In my case, the tests finished too early so I got:
The function startServer in app.js didn't complete in time so app.angularFullstack was undefined.
I worked around it but was wondering if anyone else ran into this.
The text was updated successfully, but these errors were encountered: