Janatbek / wallaby-playground

Setting up wallaby.js for the projects
0 stars 1 forks source link

Injector #3

Open Janatbek opened 7 years ago

Janatbek commented 7 years ago

@ArtemGovorov The problem is in wallabyTest.ts file In order to have below method in my test TestBed.initTestEnvironment( BrowserDynamicTestingModule, platformBrowserDynamicTesting() ); I am getting error from wallaby: Error: Cannot set base providers because it has already been called

I f I comment this out the error goes away.

Do I need this file if wallaby.js can work without this file?

noerrorinservice

errorin service

ArtemGovorov commented 7 years ago

@Janatbek

The wallabyTest.ts file is executed before all of your tests once.

This method:

TestBed.initTestEnvironment( BrowserDynamicTestingModule, platformBrowserDynamicTesting() 

can only be called once, otherwise angular throws the Cannot set base providers because it has already been called error.

So I'd rather suggest you remove your beforeAll test hook, because it is not required. Your karma runner also has the method called once here, so you don't need the beforeAll test hook.

Janatbek commented 7 years ago

But if I remove it, my test fails.

ArtemGovorov commented 7 years ago

@Janatbek Please update the repo so that I could reproduce the issue.

Janatbek commented 7 years ago

https://github.com/Janatbek/wallaby-playground/tree/injector-of-null it's in this branch

Janatbek commented 7 years ago

the video screen shot https://www.youtube.com/watch?v=lo7OeTSzZ2k&feature=youtu.be

you can fast forward the video npm test takes too long to execute.

ArtemGovorov commented 7 years ago

https://github.com/Janatbek/wallaby-playground/tree/injector-of-null

Just ran wallaby on the branch code, everything is working as expected for me: w

the video screen shot

The video is unavailable.

Janatbek commented 7 years ago

the code is just to show you my karma config wallaby and and soe code, but actual code is huge and I cannot upload it here. It is explained in the video

ArtemGovorov commented 7 years ago

I understand, and I wasn't suggesting to upload your real code. Try isolating the issue in your real project (by only including a single problematic spec file in the tests list, removing dependencies that a re not required to reproduce the issue, etc.) and then updating your sample repo so that I can reproduce it.

Janatbek commented 7 years ago

https://www.youtube.com/watch?v=lo7OeTSzZ2k the video is public now

ArtemGovorov commented 7 years ago

Thanks for publishing the video.

It looks like your karma setup doesn't have the equivalent of the wallabyTest file (where it bootstraps the environment). It's a bit strange, because all project I have seen normally have one.

Anyway, here's what you can do: https://github.com/Janatbek/wallaby-playground/pull/4. This way you may still have your beforeAll call with the TestBed.initTestEnvironment call, which will just be ignored by wallaby (because it had already called it in the wallabyTest file).