Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CezaryDanielNowak/e62faeb0aba04fc510139f0de4b17738 to your computer and use it in GitHub Desktop.
Save CezaryDanielNowak/e62faeb0aba04fc510139f0de4b17738 to your computer and use it in GitHub Desktop.
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