serverless/test/integration/functionDestinations.test.js
2020-09-09 11:17:21 +02:00

43 lines
1.3 KiB
JavaScript

'use strict';
const { expect } = require('chai');
const awsRequest = require('@serverless/test/aws-request');
const fixtures = require('../fixtures');
const { confirmCloudWatchLogs } = require('../utils/misc');
const { deployService, removeService } = require('../utils/integration');
describe('Function destinations Integration Test', function() {
this.timeout(1000 * 60 * 20); // Involves time-taking deploys
let stackName;
let servicePath;
const stage = 'dev';
before(async () => {
const serviceData = await fixtures.setup('functionDestinations');
({ servicePath } = serviceData);
const serviceName = serviceData.serviceConfig.service;
stackName = `${serviceName}-${stage}`;
await deployService(servicePath);
});
after(async () => {
if (!servicePath) return;
await removeService(servicePath);
});
it('on async invoke should invoke destination target', async () =>
confirmCloudWatchLogs(
`/aws/lambda/${stackName}-target`,
async () => {
await awsRequest('Lambda', 'invoke', {
FunctionName: `${stackName}-trigger`,
InvocationType: 'Event',
});
},
{ checkIsComplete: events => events.length }
).then(events => {
expect(events.length > 0).to.equal(true);
}));
});