3
votes

I am getting "Process Exited before Completing request error with following handler. Why is my callback not called after executing all test ?

"errorMessage": "RequestId: 000e2a3b-8c5f-11e8-91f4-27bcbb5fbff8 Process exited before completing request" START RequestId: 16d47a14-8c61-11e8-b782-b7d39e21e674 Version: $LATEST 2018-07-20T21:08:46.755Z 16d47a14-8c61-11e8-b782-b7d39e21e674 Jasmine started 2018-07-20T21:08:46.771Z 16d47a14-8c61-11e8-b782-b7d39e21e674 Tests Test 2018-07-20T21:08:46.899Z 16d47a14-8c61-11e8-b782-b7d39e21e674
2018-07-20T21:08:46.899Z 16d47a14-8c61-11e8-b782-b7d39e21e674 Visit website 2018-07-20T21:08:46.900Z 16d47a14-8c61-11e8-b782-b7d39e21e674
\u001b[32m✓ Visit Google\u001b[39m 2018-07-20T21:08:46.900Z 16d47a14-8c61-11e8-b782-b7d39e21e674
2018-07-20T21:08:46.901Z 16d47a14-8c61-11e8-b782-b7d39e21e674 Executed 1 of 1 spec\u001b[32m SUCCESS\u001b[39m in 0.147 sec. END RequestId: 16d47a14-8c61-11e8-b782-b7d39e21e674 REPORT RequestId: 16d47a14-8c61-11e8-b782-b7d39e21e674 Duration: 432.18 ms Billed Duration: 500 ms Memory Size: 3008 MB Max Memory Used: 41 MB
RequestId: 16d47a14-8c61-11e8-b782-b7d39e21e674 Process exited before completing request

My Handler

exports.handler = async (event, context, callback) =>{
const Jasmine = require('jasmine');
const { SpecReporter } = require('jasmine-spec-reporter');
const reporter = new SpecReporter();
const jasmine = new Jasmine();

jasmine.loadConfig({
  spec_dir: 'specs',
  spec_files: [
    '**/*spec.js',
],
  helpers: [
 ]
});

// Setup reporter
jasmine.env.clearReporters();
jasmine.addReporter(reporter);
const customReporter = {
specStarted(specInfo) {
console.log(`...Test: ${specInfo.description}`);
 },
};
//jasmine.addReporter(customReporter);

// TODO: Consider blocking log output for code outside of tests.

await jasmine.execute();
console.log(`Tests Test`);
callback(null, "success");
}
1

1 Answers

0
votes

I fixed this by adding onComplete function and doing the callback there. I also removed the "async" nature of the handler. I think there is more efficient way to do this, so let me know if any other suggestion

jasmine.onComplete(function(passed) {
 if(passed) {
 callback(null, "success")
 }
 else {
  callback(null, "failed")
 }
});