Skip to content

Commit

Permalink
Added custom test template config
Browse files Browse the repository at this point in the history
  • Loading branch information
thedrivendev committed Jul 1, 2020
1 parent aece13b commit 3af3f3f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/create-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ const BbPromise = require('bluebird');
const writeFile = BbPromise.promisify(fse.writeFile);
const ensureDir = BbPromise.promisify(fse.ensureDir);

const testTemplateFile = path.join('templates', 'test-template.ejs');

const defaultTestPath = '__tests__';

const writeTestfile = (serverless, options, testConfig) => {
const templateFile = path.join(__dirname, testTemplateFile);
let templateFile = path.join(__dirname, 'templates', 'test-template.ejs');

if (serverless.service.custom &&
serverless.service.custom['serverless-jest-plugin'] &&
serverless.service.custom['serverless-jest-plugin'].testTemplate) {
templateFile = path.join(serverless.config.servicePath,
serverless.service.custom['serverless-jest-plugin'].testTemplate);
}
const templateString = utils.getTemplateFromFile(templateFile);
const content = ejs.render(templateString, {
functionName: testConfig.functionName,
Expand Down

0 comments on commit 3af3f3f

Please sign in to comment.