serverless/tests/integration/Serverless.js
Philipp Muens 7f95047a5c Add CLI switch for tests
This switch enables a way to attach additional functionality to the serverless
instance when running tests.
2016-05-20 19:09:12 +02:00

33 lines
883 B
JavaScript

'use strict';
/**
* Test: Serverless Integration
*/
const expect = require('chai').expect;
const exec = require('child_process').exec;
const path = require('path');
const TestsPlugin = require('../../lib/plugins/Tests/Tests');
describe('Serverless integration tests', () => {
it('should successfully run the "serverless test integration" command', (done) => {
const testsPlugin = new TestsPlugin();
const execute = (command, callback) => {
exec(command, (error, stdout, stderr) => {
if (stderr) {
throw new Error(stderr);
}
callback(stdout);
});
};
execute(`${path.join(process.env.PWD, 'bin', 'serverless')} test integration --test`,
(consoleOutput) => {
const commands = JSON.parse(consoleOutput);
expect(commands).to.deep.equal(testsPlugin.commands);
done();
});
});
});