Skip to content

Commit

Permalink
Refactor error return from opts parse
Browse files Browse the repository at this point in the history
It's a lot clearer as to what is going on if the parse error in the
mapping layer for locator.click is returned before the promise is
initiated.
  • Loading branch information
ankur22 committed Jan 19, 2024
1 parent 53a4d99 commit eddc74e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions browser/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,15 @@ func mapLocator(vu moduleVU, lo *common.Locator) mapping {

return lo.Clear(copts) //nolint:wrapcheck
},
"click": func(opts goja.Value) *goja.Promise {
"click": func(opts goja.Value) (*goja.Promise, error) {
popts, err := parseFrameClickOptions(vu.Context(), opts, lo.Timeout())
if err != nil {
return nil, err
}

return k6ext.Promise(vu.Context(), func() (any, error) {
if err != nil {
return nil, err
}

err = lo.Click(popts)
return nil, err //nolint:wrapcheck
})
return nil, lo.Click(popts) //nolint:wrapcheck
}), nil
},
"dblclick": lo.Dblclick,
"check": lo.Check,
Expand Down

0 comments on commit eddc74e

Please sign in to comment.