Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bundle-stdin option #2

Merged
merged 2 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ const opts = yargs(hideBin(process.argv))
group: 'Options:',
describe: 'Bundle the resolved spec using the given command'
})
.option('bundle-stdin', {
type: 'string',
group: 'Options:',
describe:
'Pass a synthetic file as stdin to the bundler with "require" or "import" statements for each spec file'
})
.option('esm', {
type: 'boolean',
group: 'Options:',
Expand All @@ -57,28 +63,32 @@ const opts = yargs(hideBin(process.argv))
'Options:': 'Other:'
})
.example(
'$0 --driver puppeteer --bundle browserify "./src/**/*.test.js" ',
'$0 --driver puppeteer --bundle browserify "./src/**/*.test.js"',
'Bundle all files matching the given spec using browserify and run them using @mochify/driver-puppeteer.'
)
.example(
'$0 --esm --reporter dot --driver puppeteer "./src/**/*.test.js" ',
'$0 --driver playwright --bundle esbuild --bundle-stdin "require" "./src/**/*.test.js"',
'Bundle all files matching the given spec using esbuild and run them using @mochify/driver-playwright.'
)
.example(
'$0 --esm --reporter dot --driver puppeteer "./src/**/*.test.js"',
'Run all tests matching the given spec as ES modules in puppeteer and use the "dot" reporter for output.'
)
.example(
'$0 "./src/**/*.test.js" ',
'$0 "./src/**/*.test.js"',
'Run all tests matching the given spec using the default configuration lookup.'
)
.example(
'$0 --config mochify.webdriver.js "./src/**/*.test.js" ',
'$0 --config mochify.webdriver.js "./src/**/*.test.js"',
'Run all tests matching the given spec using the configuration from mochify.webdriver.js.'
)
.example(
'browserify "./src/**/*.test.js" | $0 -',
'browserify "./src/**/*.test.js" | $0 -',
'Read a bundled test suite from stdin.'
)
.epilogue(
`Mochify Resources:
GitHub: https://github.com/mantoni/mochify.js`
GitHub: https://github.com/mochify-js`
)
.wrap(process.stdout.columns ? Math.min(process.stdout.columns, 80) : 80)
.parse();
Expand All @@ -89,6 +99,9 @@ if (opts['driver-option']) {
if (opts['server-option']) {
opts.server_options = opts['server-option'];
}
if (opts['bundle-stdin']) {
opts.bundle_stdin = opts['bundle-stdin'];
}

if (opts._.length) {
if (opts._[0] === '-') {
Expand Down
Loading