From 99deab69bcff5dd23c2810ba3268e6416c3a1834 Mon Sep 17 00:00:00 2001 From: Ralph Date: Thu, 16 Jul 2020 17:47:51 +0100 Subject: [PATCH 1/3] fix(docstring.feature): extend DocString.feature tests to cover failing scenario DocString.feature will fail when ES6 template literals are present in the DocString. --- cypress/integration/DocString.feature | 11 ++++++++++- cypress/support/step_definitions/docString.js | 9 +++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/cypress/integration/DocString.feature b/cypress/integration/DocString.feature index a18969df..c1fb5342 100644 --- a/cypress/integration/DocString.feature +++ b/cypress/integration/DocString.feature @@ -9,4 +9,13 @@ Feature: Being a plugin handling DocString scenario expect(true).to.equal(true) variableToVerify = "hello world" """ - Then I ran it and verify that it executes it \ No newline at end of file + Then I ran it and verify that it executes it + + Scenario: DocString + When I use DocString for freemarker code like this + """ +
+

${ article.title }

+
+ """ + Then I can interpret it as a string diff --git a/cypress/support/step_definitions/docString.js b/cypress/support/step_definitions/docString.js index f48e15a9..5c45bc8b 100644 --- a/cypress/support/step_definitions/docString.js +++ b/cypress/support/step_definitions/docString.js @@ -13,3 +13,12 @@ then("I ran it and verify that it executes it", () => { eval(code); expect(variableToVerify).to.equal("hello world"); }); + +let freemarkerSnippet = ""; +when("I use DocString for freemarker code like this", dataString => { + freemarkerSnippet = dataString; +}); + +then("I can interpret it as a string", () => { + expect(freemarkerSnippet).to.be.a("string"); +}); From 83ef60fb0ffefd9efcd3aae3dfb0c7d4c2ed6b82 Mon Sep 17 00:00:00 2001 From: Ralph Date: Sat, 18 Jul 2020 09:11:13 +0100 Subject: [PATCH 2/3] fix(loader.js): pass spec as string to createTestsFromFeature fn Suggested fix. Unfortunately test case still fails. re #415 --- lib/loader.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/loader.js b/lib/loader.js index 6edabd17..6c8f5faa 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -11,11 +11,11 @@ const { getCucumberJsonConfig } = require("./getCucumberJsonConfig"); const createCucumber = (filePath, cucumberJson, spec, toRequire, name) => ` ${cucumberTemplate} - + window.cucumberJson = ${JSON.stringify(cucumberJson)}; describe(\`${name}\`, function() { ${toRequire.join("\n")} - createTestsFromFeature('${filePath}', \`${jsStringEscape(spec)}\`); + createTestsFromFeature('${filePath}', '${jsStringEscape(spec)}'); }); `; From 706da1ca33ef1685d593d16ba49635cee8ac5269 Mon Sep 17 00:00:00 2001 From: Ralph Saunders Date: Sat, 18 Jul 2020 18:49:42 +0100 Subject: [PATCH 3/3] fix(featuresloader.js): pass spec as string to createTestsFromFeature fn All test cases now passing fix #415 --- lib/featuresLoader.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/featuresLoader.js b/lib/featuresLoader.js index 266db344..796c2484 100644 --- a/lib/featuresLoader.js +++ b/lib/featuresLoader.js @@ -23,7 +23,7 @@ const createCucumber = ( window.cucumberJson = ${JSON.stringify(cucumberJson)}; var moduleCache = arguments[5]; - + function clearFromCache(moduleId, instance){ if(isWebpack()){ delete require.cache[moduleId]; @@ -31,7 +31,7 @@ const createCucumber = ( clearFromCacheBrowserify(instance); } } - + function isWebpack(){ return !!require.cache } @@ -60,10 +60,10 @@ const createCucumber = ( nonGlobalToRequire .find(fileSteps => fileSteps[filePath]) [filePath].join("\n")} - - createTestsFromFeature('${path.basename(filePath)}', \`${jsStringEscape( + + createTestsFromFeature('${path.basename(filePath)}', '${jsStringEscape( spec - )}\`); + )}'); }) ` )