diff --git a/lib/create-test.js b/lib/create-test.js index ceb05d2..a016823 100644 --- a/lib/create-test.js +++ b/lib/create-test.js @@ -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,