Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ngx-socket-io ng test "NullInjectorError: No provider for WrappedSocket!"

Tags:

angular

I using ngx-socket-io and it's working fine in development. But I'm having a problem when I run the ng test.

It gives me error NullInjectorError: No provider for WrappedSocket!

Here is my spec.ts

const IO_CONFIG:SocketIoConfig = {url:'http://localhost:3000,options:{}}
  
describe(...,()=>{
  beforeEach(()=>{
    TestBed.configureTestingModule({
     imports:[
       ...
       SocketIoModule.forRoot(IO_CONFIG)
       ...
     ]
    })
  })
})
like image 215
mynameisx Avatar asked Oct 22 '25 03:10

mynameisx


1 Answers

try to add this code to "imports" SocketIoModule.forRoot({ url: environment.apiUrl, options: { transports: ['websocket'], reconnection: true } })

like image 121
jawdat abdallh Avatar answered Oct 23 '25 16:10

jawdat abdallh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!