-
Notifications
You must be signed in to change notification settings - Fork 86
refactor: Simplify test-runner logic #196
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
Conversation
@trevor-bliss The entire test suite has to be rebuilt reworked after this change. Before I do this I would like to get your feeling on this change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a few suggestions but looks great overall!
function getJestArgs(argv) { | ||
// Extract known options from parsed arguments | ||
const knownOptions = Object.keys(argv) | ||
.filter((key) => argv[key] && JEST_PASSTHROUGH_OPTIONS.has(key)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking through this repository, it doesn't look like we have any logic that requires explicit default values of false
for boolean arguments so I think we can remove the defaults from the configuration in this file. That would make this code more robust since it wouldn't need to change if we ever introduce new non-boolean arguments with truthy values.
Otherwise, my second preference would be to change this to:
.filter((key) => argv[key] && JEST_PASSTHROUGH_OPTIONS.has(key)) | |
.filter((key) => argv[key] !== false && JEST_PASSTHROUGH_OPTIONS.has(key)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great. Tried it out locally against lwc-recipe and things look like they're running normally.
@trevor-bliss Do you mind doing another round of review now I have reworked the test suite? |
@@ -16,7 +16,7 @@ | |||
}, | |||
"scripts": { | |||
"check-license-headers": "node ./scripts/checkLicenseHeaders.js", | |||
"lint": "eslint src/", | |||
"lint": "eslint src/ tests/", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test files were not linted before.
|
||
process.on('unhandledRejection', reason => { | ||
runJest(args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delegating all the process.exit
handling to the bin file instead of having this all around the code base.
}); | ||
}); | ||
}; | ||
const promiseExec = promisify(exec); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a beautiful help in Node.js for doing this =)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is an attempt to simplify the test runner logic:
Fixes #36