Repository: asyncapi/generator (js)

Issue:
Extract all debug logs texts to a separate file
#### Reason/Context
We have `debug` flag that enables logging of some additional info for the user. Log texts are "hardcoded" in code and therefore again hardcoded in tests.

#### Description
Move log message texts to a separate file and then import log messages in code and tests. This way, when you change or improve a log message, you do it in one file and do not touch tests at all


Pull request:
refactor: all the debug logs extracted to a new separate file
<!--   Thank you for your contribution. Before you submit the pull request:
1. Follow contributing guidelines and make sure PR title follows Conventional Commits specification -> https://github.com/asyncapi/generator/blob/master/CONTRIBUTING.md
2. Test your changes and attach their results to the pull request.
3. Update the relevant documentation.
-->

**Description**

- ...
- ...
- ...

**Related issue(s)**
<!-- If you refer to a particular issue, provide its number, othewise, remove this section.
For example, `Resolves #123`, `Fixes #43`, or `See also #33`. The 3rd option will not automatically close the issue after the merge. --> Fixes #533

Patch:
diff --git a/lib/generator.js b/lib/generator.js
index 0e1474c..1bb695a 100644
--- a/lib/generator.js
+++ b/lib/generator.js
@@ -47,6 +47,8 @@ const TRANSPILED_TEMPLATE_LOCATION = '__transpiled';
 const TEMPLATE_CONTENT_DIRNAME = 'template';
 const GENERATOR_OPTIONS = ['debug', 'disabledHooks', 'entrypoint', 'forceWrite', 'install', 'noOverwriteGlobs', 'output', 'templateParams'];
 
+const logMessage = require('./logMessages');
+
 const shouldIgnoreFile = filePath =>
   filePath.startsWith(`.git${path.sep}`);
 
@@ -251,7 +253,7 @@ class Generator {
     if (!asyncapiString || typeof asyncapiString !== 'string') throw new Error('Parameter "asyncapiString" must be a non-empty string.');
 
     /** @type {String} AsyncAPI string to use as a source. */
-    this.originalAsyncAPI = asyncapiString; 
+    this.originalAsyncAPI = asyncapiString;
 
     /** @type {AsyncAPIDocument} Parsed AsyncAPI schema. See {@link https://github.com/asyncapi/parser-js/blob/master/API.md#module_@asyncapi/parser+AsyncAPIDocument|AsyncAPIDocument} for details on object structure. */
     this.asyncapi = await parse(asyncapiString, parserOptions);
@@ -350,23 +352,23 @@ class Generator {
           installedPkg = getTemplateDetails(this.templateName, PACKAGE_JSON_FILENAME);
           pkgPath = installedPkg && installedPkg.pkgPath;
           packageVersion = installedPkg && installedPkg.version;
-          log.debug(`Template sources taken from ${pkgPath}.`);
-          if (packageVersion) log.debug(`Version of the template is ${packageVersion}.`);
+          log.debug(logMessage.templateSource(pkgPath));
+          if (packageVersion) log.debug(logMessage.templateVersion(packageVersion));
 
           return resolve({
             name: installedPkg.name,
             path: pkgPath
           });
         } catch (e) {
-          log.debug(`Unable to resolve template location at ${pkgPath}. Package is not available locally`, e);
+          log.debug(logMessage.packageNotAvailable(pkgPath), e);
           // We did our best. Proceed with installation...
         }
       }
 
-      const debugMessage = force ? 'because you passed --install flag' : 'because the template cannot be found on disk';
-      log.debug(`Template installation started ${  debugMessage}`);
+      const debugMessage = force ? logMessage.TEMPLATE_INSTALL_FLAG_MSG : logMessage.TEMPLATE_INSTALL_DISK_MSG;
+      log.debug(logMessage.installationDebugMessage(debugMessage));
 
-      if (isFileSystemPath(this.templateName)) log.debug('Installation of template located on disk technically means symlink creation betweed node_modules of the generator and template sources. Your local template must have its own node_modules, "npm install" is not triggered.');
+      if (isFileSystemPath(this.templateName)) log.debug(logMessage.NPM_INSTALL_TRIGGER);
 
       const arb = new Arborist({
         path: ROOT_DIR
@@ -381,13 +383,13 @@ class Generator {
 
         const addResult = arb[Symbol.for('resolvedAdd')];
         if (!addResult) return reject('Unable to resolve the name of the added package. It was most probably not added to node_modules successfully');
-        
+
         const packageName = addResult[0].name;
         const packageVersion = installResult.children.get(packageName).version;
         const packagePath = installResult.children.get(packageName).path;
 
-        if (!isFileSystemPath(this.templateName)) log.debug(`Template ${packageName} successfully installed in ${packagePath}`);
-        if (packageVersion) log.debug(`Version of used template is ${packageVersion}.`);
+        if (!isFileSystemPath(this.templateName)) log.debug(logMessage.templateSuccessfullyInstalled(packageName, packagePath));
+        if (packageVersion) log.debug(logMessage.templateVersion(packageVersion));
 
         return resolve({
           name: packageName,
@@ -567,7 +569,7 @@ class Generator {
     const setFileTemplateNameHookName = 'setFileTemplateName';
     let filename = name;
     if (this.isHookAvailable(setFileTemplateNameHookName)) {
-      const filenamesFromHooks = await this.launchHook(setFileTemplateNameHookName, {originalFilename: filename});
+      const filenamesFromHooks = await this.launchHook(setFileTemplateNameHookName, { originalFilename: filename });
       //Use the result of the first hook
       filename = filenamesFromHooks[0];
     } else {
@@ -597,7 +599,7 @@ class Generator {
    * @param {Object} [extraTemplateData] Extra data to pass to the template.
    */
   async renderAndWriteToFile(asyncapiDocument, templateFilePath, outputpath, extraTemplateData) {
-    const renderContent =  await this.renderFile(asyncapiDocument, templateFilePath, extraTemplateData);
+    const renderContent = await this.renderFile(asyncapiDocument, templateFilePath, extraTemplateData);
     if (renderContent === undefined) {
       return;
     } else if (isReactTemplate(this.templateConfig)) {
@@ -636,12 +638,12 @@ class Generator {
         },
       }, this.templateConfig.conditionalFiles[relativeSourceFile].subject);
 
-      if (!source) return log.debug(`${relativeSourceFile} was not generated because ${this.templateConfig.conditionalFiles[relativeSourceFile].subject} specified in template configuration in conditionalFiles was not found in provided AsyncAPI specification file`);
+      if (!source) return log.debug(logMessage.relativeSourceFileNotGenerated(relativeSourceFile, this.templateConfig.conditionalFiles[relativeSourceFile].subject));
 
       if (source) {
         const validate = this.templateConfig.conditionalFiles[relativeSourceFile].validate;
         const valid = validate(source);
-        if (!valid) return log.debug(`${relativeSourceFile} was not generated because condition specified for this file in template configuration in conditionalFiles matched`);
+        if (!valid) return log.debug(logMessage.conditionalFilesMatched(relativeSourceFile));
       }
     }
 
diff --git a/lib/logMessages.js b/lib/logMessages.js
new file mode 100644
index 0000000..33ac656
--- /dev/null
+++ b/lib/logMessages.js
@@ -0,0 +1,55 @@
+const TEMPLATE_INSTALL_FLAG_MSG = 'because you passed --install flag';
+
+const TEMPLATE_INSTALL_DISK_MSG = 'because the template cannot be found on disk';
+
+const NODE_MODULES_INSTALL ='Remember that your local template must have its own node_modules installed first, \"npm install\" is not triggered by the generator.';
+
+const NPM_INSTALL_TRIGGER = 'Installation of template located on disk technically means symlink creation betweed node_modules of the generator and template sources. Your local template must have its own node_modules, "npm install" is not triggered.';
+
+function templateVersion(ver) {  
+  return `Version of used template is ${ver}.`;
+} 
+
+function templateSource(localHtmlTemplate) {
+  return `Template sources taken from ${localHtmlTemplate}.`;
+} 
+
+function templateNotFound(templateName) {
+  return `${templateName} not found in local dependencies but found it installed as a global package.`;
+} 
+
+function packageNotAvailable(pkgPath) {
+  return `Unable to resolve template location at ${pkgPath}. Package is not available locally.`;
+}
+
+function installationDebugMessage(debugMessage) {
+  return `Template installation started ${debugMessage}.`;
+}
+
+function templateSuccessfullyInstalled(packageName, packagePath) {
+  return `Template ${packageName} successfully installed in ${packagePath}.`;
+}
+
+function relativeSourceFileNotGenerated(relativeSourceFile , subject) {
+  return `${relativeSourceFile} was not generated because ${subject} specified in template configuration in conditionalFiles was not found in provided AsyncAPI specification file.`;
+}
+
+function conditionalFilesMatched(relativeSourceFile) {
+  return `${relativeSourceFile} was not generated because condition specified for this file in template configuration in conditionalFiles matched.`;
+}
+
+module.exports = {
+  TEMPLATE_INSTALL_FLAG_MSG,
+  TEMPLATE_INSTALL_DISK_MSG,
+  NODE_MODULES_INSTALL,
+  NPM_INSTALL_TRIGGER,
+  templateVersion,
+  templateSource,
+  templateNotFound,
+  packageNotAvailable,
+  installationDebugMessage,
+  templateSuccessfullyInstalled,
+  relativeSourceFileNotGenerated,
+  conditionalFilesMatched
+
+};
\ No newline at end of file
diff --git a/lib/utils.js b/lib/utils.js
index 6baf01a..7bdbaa5 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -9,6 +9,8 @@ const globalDirs = require('global-dirs');
 const log = require('loglevel');
 const packageJson = require('../package.json');
 
+const logMessage = require('./logMessages.js');
+
 const utils = module.exports;
 
 utils.lstat = util.promisify(fs.lstat);
@@ -170,7 +172,7 @@ utils.getTemplateDetails = (name, PACKAGE_JSON_FILENAME) => {
   if (utils.isFileSystemPath(name)) {
     pkgPath = path.resolve(name);
     
-    log.debug('Remember that your local template must have its own node_modules installed first, "npm install" is not triggered by the generator.');
+    log.debug(logMessage.NODE_MODULES_INSTALL);
   } else {
     //first trying to resolve package in local dependencies of generator or the project that uses generator library
     //return path doesn't point to package.json
@@ -189,7 +191,7 @@ utils.getTemplateDetails = (name, PACKAGE_JSON_FILENAME) => {
       }
 
       if (pkgPackageJsonPath) {
-        log.debug(`${name} not found in local dependencies but found it installed as a global package.`);
+        log.debug(logMessage.templateNotFound(name));
         //removing package.json from path
         pkgPath = path.dirname(pkgPackageJsonPath);
       }
diff --git a/package-lock.json b/package-lock.json
index 27a7c97..583a3f5 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -14877,9 +14877,9 @@
       "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
     },
     "v8-compile-cache": {
-      "version": "2.2.0",
-      "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.2.0.tgz",
-      "integrity": "sha512-gTpR5XQNKFwOd4clxfnhaqvfqMpqEwr4tOtCyz4MtYZX2JYhfr1JvBFKdS+7K/9rfpZR3VLX+YWBbKoxCgS43Q==",
+      "version": "2.3.0",
+      "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz",
+      "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==",
       "dev": true
     },
     "v8-to-istanbul": {
diff --git a/package.json b/package.json
index a0fa0a1..d971874 100644
--- a/package.json
+++ b/package.json
@@ -43,10 +43,7 @@
     "generator",
     "markdown"
   ],
-  "author": {
-    "name": "Fran Mendez",
-    "email": "fmvilas@gmail.com"
-  },
+  "author": "Fran Mendez <fmvilas@gmail.com>",
   "publishConfig": {
     "access": "public"
   },


Test patch:
diff --git a/test/generator.test.js b/test/generator.test.js
index 0404b74..3ec4a81 100644
--- a/test/generator.test.js
+++ b/test/generator.test.js
@@ -7,6 +7,8 @@ const unixify = require('unixify');
 
 const dummyYAML = fs.readFileSync(path.resolve(__dirname, './docs/dummy.yml'), 'utf8');
 
+const logMessage = require('./../lib/logMessages.js');
+
 jest.mock('../lib/utils');
 jest.mock('../lib/filtersRegistry');
 jest.mock('../lib/hooksRegistry');
@@ -381,7 +383,7 @@ describe('Generator', () => {
       utils.__getTemplateDetails = undefined;
       const gen = new Generator('nameOfTestTemplate', __dirname, {debug: true});
       await gen.installTemplate();
-      expect(log.debug).toHaveBeenCalledWith('Template installation started because the template cannot be found on disk');
+      expect(log.debug).toHaveBeenCalledWith(logMessage.installationDebugMessage(logMessage.TEMPLATE_INSTALL_DISK_MSG));
       setTimeout(() => { // This puts the call at the end of the Node.js event loop queue.
         expect(arboristMock.reify).toHaveBeenCalledTimes(1);
       }, 0);
@@ -392,7 +394,7 @@ describe('Generator', () => {
       utils.__isFileSystemPathValue = false;
       const gen = new Generator('nameOfTestTemplate', __dirname);
       await gen.installTemplate(true);
-      expect(log.debug).toHaveBeenCalledWith('Template installation started because you passed --install flag');
+      expect(log.debug).toHaveBeenCalledWith(logMessage.installationDebugMessage(logMessage.TEMPLATE_INSTALL_FLAG_MSG));
       setTimeout(() => { // This puts the call at the end of the Node.js event loop queue.
         expect(arboristMock.reify).toHaveBeenCalledTimes(1);
       }, 0);
diff --git a/test/test-project/test-global.test.js b/test/test-project/test-global.test.js
index d3029e2..bb40538 100644
--- a/test/test-project/test-global.test.js
+++ b/test/test-project/test-global.test.js
@@ -10,6 +10,8 @@ const strThatShouldBeMissing = '<div class="text-sm text-gray-700 mb-2">Correlat
 const templateName = '@asyncapi/html-template';
 const tempOutputResults = '../temp/integrationTestResult';
 const fileToCheck = 'index.html';
+const logMessage = require('../../lib/logMessages');
+const version = '0.16.0';
 
 //we do not want to download chromium for html-template if it is not needed
 process.env['PUPPETEER_SKIP_CHROMIUM_DOWNLOAD'] = true;
@@ -17,23 +19,23 @@ console.log = jest.fn();
 
 describe('Testing if html was generated using global template', () => {
   jest.setTimeout(200000);
-  
+
   it('generated html should not contain information about correlationId because of older html-template version that is installed globally', async () => {
     //you always want to generate to new directory to make sure test runs in clear environment
     const outputDir = path.resolve(tempOutputResults, Math.random().toString(36).substring(7));
-        
+
     //we setup generator using template name, not path, without explicitly running installation
     //generator picks up template that is already in node_modules as it was installed before as node dependency in global packages location
     const generator = new Generator(templateName, outputDir, { forceWrite: true, debug: true, templateParams: { singleFile: true } });
     await generator.generateFromFile(dummySpecPath);
-    
+
     const file = await readFile(path.join(outputDir, fileToCheck), 'utf8');
     const isCorelationIdInHtml = file.includes(strThatShouldBeMissing);
 
     //we make sure that index.html file doesn't contain any information about correlationId because this feature was added in html-template 0.17.0 while this test uses template 0.16.0
     expect(isCorelationIdInHtml).toStrictEqual(false);
     //we make sure that logs indicate that global package was used
-    expect(console.log).toHaveBeenCalledWith(`${templateName} not found in local dependencies but found it installed as a global package.`);
-    expect(console.log).toHaveBeenCalledWith('Version of the template is 0.16.0.');
+    expect(console.log).toHaveBeenCalledWith(logMessage.templateNotFound(templateName));
+    expect(console.log).toHaveBeenCalledWith(logMessage.templateVersion(version));
   });
 });
diff --git a/test/test-project/test-project.test.js b/test/test-project/test-project.test.js
index 7abb07a..8801e90 100644
--- a/test/test-project/test-project.test.js
+++ b/test/test-project/test-project.test.js
@@ -11,7 +11,9 @@ const strThatShouldBeMissing = '<div class="text-sm text-gray-700 mb-2">Correlat
 const templateName = '@asyncapi/html-template';
 const tempOutputResults = '../temp/integrationTestResult';
 const fileToCheck = 'index.html';
-const templateInstallStartedMsg = 'Template installation started because you passed --install flag';
+const version = '0.16.0';
+const source = path.join(__dirname, 'node_modules', templateName);
+const logMessage = require('../../lib/logMessages.js');
 
 //we do not want to download chromium for html-template if it is not needed
 process.env['PUPPETEER_SKIP_CHROMIUM_DOWNLOAD'] = true;
@@ -19,31 +21,31 @@ console.log = jest.fn();
 
 describe('Testing if html was generated with proper version of the template', () => {
   jest.setTimeout(200000);
-  
+
   it('generated html should not contain information about correlationId because of older html-template version that is already installed', async () => {
     //you always want to generate to new directory to make sure test runs in clear environment
     const outputDir = path.resolve(tempOutputResults, Math.random().toString(36).substring(7));
-        
+
     //we setup generator using template name, not path, without explicitly running installation
     //generator picks up template that is already in node_modules as it was installed before as node dependency
     const generator = new Generator(templateName, outputDir, { forceWrite: true, debug: true, templateParams: { singleFile: true } });
     await generator.generateFromFile(dummySpecPath);
-    
+
     const file = await readFile(path.join(outputDir, fileToCheck), 'utf8');
     const isCorelationIdInHtml = file.includes(strThatShouldBeMissing);
 
     //we make sure that index.html file doesn't contain any infromation about correlationId because this feature was added in html-template 0.17.0 while this test uses template 0.16.0
     expect(isCorelationIdInHtml).toStrictEqual(false);
     //we make sure that logs do not indicate that new installation is started
-    expect(console.log).not.toHaveBeenCalledWith(templateInstallStartedMsg);
-    expect(console.log).toHaveBeenCalledWith(`Template sources taken from ${path.join(__dirname, 'node_modules', templateName)}.`);
-    expect(console.log).toHaveBeenCalledWith('Version of the template is 0.16.0.');
+    expect(console.log).not.toHaveBeenCalledWith(logMessage.installationDebugMessage(logMessage.TEMPLATE_INSTALL_FLAG_MSG));
+    expect(console.log).toHaveBeenCalledWith(logMessage.templateSource(source));
+    expect(console.log).toHaveBeenCalledWith(logMessage.templateVersion(version));
   });
 
   it('generated html should contain information about correlationId because of explicit fresh installation of different template version (install: true)', async () => {
     //you always want to generate to new directory to make sure test runs in clear environment
     const outputDir = path.resolve(tempOutputResults, Math.random().toString(36).substring(7));
-    const templateVersion= '0.17.0';
+    const templateVersion = '0.17.0';
 
     const generator = new Generator(`${templateName}@${templateVersion}`, outputDir, { forceWrite: true, install: true, debug: true, templateParams: { singleFile: true } });
     await generator.generateFromFile(dummySpecPath);
@@ -53,8 +55,8 @@ describe('Testing if html was generated with proper version of the template', ()
 
     //we make sure that index.html file doesn't contain any infromation about correlationId because this feature was added in html-template 0.17.0 while this test uses template 0.16.0
     expect(isCorelationIdInHtml).toStrictEqual(true);
-    expect(console.log).toHaveBeenCalledWith(templateInstallStartedMsg);
-    expect(console.log).toHaveBeenCalledWith(`Version of used template is ${templateVersion}.`);
+    expect(console.log).toHaveBeenCalledWith(logMessage.installationDebugMessage(logMessage.TEMPLATE_INSTALL_FLAG_MSG));
+    expect(console.log).toHaveBeenCalledWith(logMessage.templateVersion(templateVersion));
   });
 
   it('generated html should not contain information about correlationId because local version of the template is old and does not have this feature (with and without install:true)', async () => {
@@ -83,28 +85,28 @@ describe('Testing if html was generated with proper version of the template', ()
 
     //run generation by passing path to local template without passing install flag, sources should be taken from local path
     const generatorWithoutInstallFlag = new Generator(localHtmlTemplate, outputDir, { forceWrite: true, debug: true, templateParams: { singleFile: true } });
-    await generatorWithoutInstallFlag.generateFromFile(dummySpecPath);    
-    
+    await generatorWithoutInstallFlag.generateFromFile(dummySpecPath);
+
     file = await readFile(path.join(outputDir, fileToCheck), 'utf8');
     isCorelationIdInHtml = file.includes(strThatShouldBeMissing);
 
     //we make sure that index.html file doesn't contain any infromation about correlationId because this feature was added in html-template 0.17.0 while this test uses template 0.16.0
     expect(isCorelationIdInHtml).toStrictEqual(false);
-    expect(console.log).toHaveBeenCalledWith(`Template sources taken from ${localHtmlTemplate}.`);
-    expect(console.log).toHaveBeenCalledWith(`Version of the template is ${templateVersion}.`);
-    expect(console.log).toHaveBeenCalledWith('Remember that your local template must have its own node_modules installed first, \"npm install\" is not triggered by the generator.');
+    expect(console.log).toHaveBeenCalledWith(logMessage.templateSource(localHtmlTemplate));
+    expect(console.log).toHaveBeenCalledWith(logMessage.templateVersion(templateVersion));
+    expect(console.log).toHaveBeenCalledWith(logMessage.NODE_MODULES_INSTALL);
 
     //run generation by passing path to local template and passing install flag, sources should be taken from local path and simlink created
     const generatorWithInstallFlag = new Generator(localHtmlTemplate, outputDir, { install: true, forceWrite: true, debug: true, templateParams: { singleFile: true } });
-    await generatorWithInstallFlag.generateFromFile(dummySpecPath);    
-    
+    await generatorWithInstallFlag.generateFromFile(dummySpecPath);
+
     file = await readFile(path.join(outputDir, fileToCheck), 'utf8');
     isCorelationIdInHtml = file.includes(strThatShouldBeMissing);
 
     //we make sure that index.html file doesn't contain any infromation about correlationId because this feature was added in html-template 0.17.0 while this test uses template 0.16.0
     expect(isCorelationIdInHtml).toStrictEqual(false);
-    expect(console.log).toHaveBeenCalledWith(templateInstallStartedMsg);
-    expect(console.log).toHaveBeenCalledWith(`Version of used template is ${ templateVersion}.`);
-    expect(console.log).toHaveBeenCalledWith('Installation of template located on disk technically means symlink creation betweed node_modules of the generator and template sources. Your local template must have its own node_modules, "npm install" is not triggered.');
+    expect(console.log).toHaveBeenCalledWith(logMessage.installationDebugMessage(logMessage.TEMPLATE_INSTALL_FLAG_MSG));
+    expect(console.log).toHaveBeenCalledWith(logMessage.templateVersion(templateVersion));
+    expect(console.log).toHaveBeenCalledWith(logMessage.NPM_INSTALL_TRIGGER);
   });
 });
\ No newline at end of file
diff --git a/test/utils.test.js b/test/utils.test.js
index 6be130a..a85a79d 100644
--- a/test/utils.test.js
+++ b/test/utils.test.js
@@ -4,6 +4,8 @@ const Generator = require('../lib/generator');
 const log = require('loglevel');
 const utils = jest.requireActual('../lib/utils');
 
+const logMessage = require('./../lib/logMessages.js');
+
 describe('Utils', () => {
   describe('#getTemplateDetails', () => {
     let resolvePkg, resolveFrom;
@@ -21,7 +23,7 @@ describe('Utils', () => {
       utils.isFileSystemPath = jest.fn(() => true);
       const templatePath = './testTemplate';
       const result = utils.getTemplateDetails(templatePath, 'package.json');
-      expect(log.debug).toHaveBeenCalledWith('Remember that your local template must have its own node_modules installed first, \"npm install\" is not triggered by the generator.');
+      expect(log.debug).toHaveBeenCalledWith(logMessage.NODE_MODULES_INSTALL);
       expect(result).toStrictEqual({
         name: templateNpmName, 
         pkgPath: path.resolve('./testTemplate')
@@ -34,8 +36,8 @@ describe('Utils', () => {
       const packagePath = path.join(Generator.DEFAULT_TEMPLATES_DIR, templateNpmName);
       resolvePkg.__resolvePkgValue = packagePath;
       const result = utils.getTemplateDetails(templateNpmName, 'package.json');
-      expect(log.debug).not.toHaveBeenCalledWith('Remember that your local template must have its own node_modules installed first, \"npm install\" is not triggered by the generator.');
-      expect(log.debug).not.toHaveBeenCalledWith(`${templateNpmName} not found in local dependencies but found it installed as a global package.`);
+      expect(log.debug).not.toHaveBeenCalledWith(logMessage.NODE_MODULES_INSTALL);
+      expect(log.debug).not.toHaveBeenCalledWith(logMessage.templateNotFound(templateNpmName));
       expect(result).toStrictEqual({
         name: templateNpmName, 
         pkgPath: packagePath
@@ -48,8 +50,8 @@ describe('Utils', () => {
       resolvePkg.__resolvePkgValue = undefined;
       resolveFrom.__resolveFromValue = path.join(Generator.DEFAULT_TEMPLATES_DIR, templateNpmName, 'package.json');
       utils.getTemplateDetails(templateNpmName, 'package.json');
-      expect(log.debug).not.toHaveBeenCalledWith('Remember that your local template must have its own node_modules installed first, \"npm install\" is not triggered by the generator.');
-      expect(log.debug).toHaveBeenCalledWith(`${templateNpmName} not found in local dependencies but found it installed as a global package.`);
+      expect(log.debug).not.toHaveBeenCalledWith(logMessage.NODE_MODULES_INSTALL);
+      expect(log.debug).toHaveBeenCalledWith(logMessage.templateNotFound(templateNpmName));
     });
 
     it('doesnt work with a url', async () => {