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

Viewed 734

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)
       ...
     ]
    })
  })
})
1 Answers

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

Related