Skip to content

Instantly share code, notes, and snippets.

@johnnieskywalker
Created August 21, 2023 16:11
Show Gist options
  • Select an option

  • Save johnnieskywalker/94dc79d0e52d233128659e6e013748e5 to your computer and use it in GitHub Desktop.

Select an option

Save johnnieskywalker/94dc79d0e52d233128659e6e013748e5 to your computer and use it in GitHub Desktop.
k6init.js, to run `node k6init.js `
const fs = require('fs');
const path = require('path');
const directories = [
'tests',
'modules',
'data'
];
console.log(`Initializing new K6 project structure in the current directory.`);
directories.forEach(dir => {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
});
const readmeContent = `# K6 Project
This is a K6 test project.
## How to run tests
To run a test, use:
\`\`\`
k6 run tests/yourTestFile.js
\`\`\`
`;
if (!fs.existsSync('README.md')) {
fs.writeFileSync('README.md', readmeContent);
}
console.log('K6 project initialization in the current directory is complete!');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment