-
Notifications
You must be signed in to change notification settings - Fork 521
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
fix(cli): allow beforeafter validation schema to run engines without flow #2396
Merged
bernardobridge
merged 4 commits into
main
from
bernardobridge/art-1547-allow-beforeafter-validate-script-schema-to-run-arbitrary
Jan 12, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b140da1
fix(cli): allow engines without flow in before/after schema
bernardobridge 653daab
test(cli): fix validate-script before/after test to not require flow
bernardobridge 4baa50b
feat(core): error when unknown engine is used in before/after
bernardobridge 2d1a1f1
Merge branch 'main' into bernardobridge/art-1547-allow-beforeafter-va…
bernardobridge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -493,6 +493,12 @@ function handleScriptHook(hook, script, hookEvents, contextVars = {}) { | |
|
||
const name = script[hook].engine || 'http'; | ||
const engine = engines.find((e) => e.__name === name); | ||
|
||
if (typeof engine === 'undefined') { | ||
throw new Error( | ||
`Failed to run ${hook} hook: unknown engine "${name}". Did you forget to include it in "config.engines.${name}"?` | ||
); | ||
} | ||
Comment on lines
+496
to
+501
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similar logic to #2101 for consistency |
||
const hookScenario = engine.createScenario(script[hook], ee); | ||
const hookContext = createContext(script, contextVars, { | ||
scenario: script[hook] | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Previously the schema would look at
config.engines
to determine this. However, this is more complicated than just looking at theengine
field within before/after itself:socketio
,ws
orhttp
, it needs flow. Otherwise it does not require flow (e.g. custom engine orplaywright
).Looking at
config.engines
doesn't actually make sense, since you could be putting a config there for an engine you're using in your scenario, but not inbefore/after
.