Skip to content

Commit 0278363

Browse files
authored
docs: Update emulating-ijsruntime.md (#1487)
* Update emulating-ijsruntime.md Adding doc for what I think is likely to be a common use case for testing methods that return IJSObjectReference instances. * PR feedback on updating emulating-ijsruntime.md Updated the suggested addition to be in the 3rd person, impersonal perspective to match the rest of the doc.
1 parent f246f7a commit 0278363

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

docs/site/docs/test-doubles/emulating-ijsruntime.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ var moduleInterop = JSInterop.SetupModule("hello.js");
8888
moduleInterop.SetupVoid("world");
8989
```
9090

91+
When testing methods that return an `IJSObjectReference`, such as `await JsRuntime.InvokeAsync<IJSObjectReference>("SomeModule.GetInstance")`, the same process can be used with the identifier associated with the interoperation, configuring the `IJSObjectReference` in the same manner as a module.
92+
93+
```csharp
94+
var objectReference = JSInterop.SetupModule(matcher => matcher.Identifier == "SomeModule.GetInstance");
95+
objectReference.SetupVoid("world");
96+
```
97+
9198
### Module Interop Mode
9299

93100
By default, a module Interop inherits the `Mode` setting from the root JSInterop in bUnit. However, you can override it explicitly and have it in a different mode from another module's Interop or the root JSInterop. Just set the `Mode` property, e.g.:

0 commit comments

Comments
 (0)