Created
April 4, 2024 08:47
-
-
Save CezaryDanielNowak/e62faeb0aba04fc510139f0de4b17738 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const process = require('process'); | |
const componentsPath = __dirname + '/components/'; | |
fs.readdirSync(componentsPath).forEach((componentName) => { | |
console.log(componentName); | |
try { | |
// Enter component dir | |
let componentPath = componentsPath + componentName; | |
//create a file inside each components with name of the component | |
fs.writeFileSync(`${componentPath}/${componentName}.cy.js`, | |
`import React from 'react'; | |
import ${componentName} from './${componentName}'; | |
const selector = '.ts-${componentName}'; | |
describe('<${componentName} />', () => { | |
it('should render ${componentName}', () => { | |
cy.mount(<${componentName}>test</${componentName}>); | |
}); | |
}); | |
` | |
); | |
console.log("File Created Successfully"); | |
} catch (err) { | |
console.error("Error while changing directory"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment