diff --git a/lib/cypress-plugin/modifySpec.js b/lib/cypress-plugin/modifySpec.js index abe03ac..b0e4bae 100644 --- a/lib/cypress-plugin/modifySpec.js +++ b/lib/cypress-plugin/modifySpec.js @@ -22,6 +22,13 @@ const path = require('path'); * @returns {String} - New spec file with added before block */ module.exports = (fileContents, version, source, target) => { + const re = /(?:\.([^.]+))?$/; + + // Only parse the following files. + if (!['js', 'jsx', 'ts', 'tsx'].includes(re.exec(source)[0])) { + return fileContents; + } + const beforeBlock = esprima.parseScript(` before(() => { const path = require('path');