Closed benm-eras closed 2 years ago
Well, i think the issue is:
See source code here: https://github.com/Daddoon/Blazor.Polyfill/blob/13c1c251f9488aea87ab2b912421a63297598141/src/Blazor.Polyfill.Server/BlazorPolyfillMiddlewareExtensions.cs
I'm not a Unit testing expert. So i would like to know, is yours tests all launched in the same AppDomain / Memory at unit testing ?
I think the error would probably disappear if each tests is loaded in a different AppDomain, as React would not be statically registered twice i imagine, same for low-level Javascript Engine library, at least not in the shared memory.
Keep me informed !
Firstly, thank you for this awesome library, without it I wouldn't be able to use Blazor!
I am getting a
NullReferenceException
on start up when running more than one unit test usingMicrosoft.VisualStudio.TestTools.UnitTesting.WebApplicationFactory
. I have created a minimal reproduction (just the Blazor Server template with Blazor.Polyfill and a test project added) of the issue here, just run all the tests (there are only 2) at once and you should get the following exception:Rather confusingly I named my project
Blazor.Polyfill
so it's not abundantly clear in the stack trace above, but my call to add your middleware withBlazor.Polyfill.Server.BlazorPolyfillMiddlewareExtensions.UseBlazorPolyfill(IApplicationBuilder builder)
is the (slightly) bold line above.My tests all pass when I run them one at a time, and I have turned off the option to run tests in parallel, but if I try running more than one test at a time I get the exception above.
Do you have any ideas?
UPDATE:
I have fixed an issue with my reproduction project, I messed up when adding to source control and excluded the test project