Skip to content

Omitting a call to JSRuntimeInvocationHandler during JSInterop set up causes test to not halt #1746

@RiRiSharp

Description

@RiRiSharp

Describe the bug

Set up a test for a call to a function which needs IJSRuntime, omit a call to JSRuntimeInvocationHandler. Normally one would add SetVoidResult(), SetCanceled() or SetException(ex). Then, the test does not halt with no indication of what is misconfigured.

Example:
Testing this component:

private async Task SomeFunction(IJSRuntime runTime)
{
    await runTime.InvokeVoidAsync("someFunction");
}

With this test:

[Fact]
public async Task ThisTestDoesNotHalt()
{
    // Arrange
    var ctx = new TestContext();
    ctx.JSInterop.SetupVoid("someFunction");
      
    // Act
    await SomeFunction(ctx.JSInterop.JSRuntime);
        
    // Assert
    _testOutputHelper.WriteLine("Halting test has succeeded");
}

Results in no output since this test does not halt.

Expected behavior:

I would expect the test to throw some exception or indicate in some other way that the framework is not able to handle such a set up.

Version info:

  • bUnit version: 1.40
  • .NET Runtime and Blazor version: .NET 9.0.7
  • OS type and version: Windows 11 23H2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions