Janatbek / wallaby-playground

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

Update wallabyTest.ts #4

Closed ArtemGovorov closed 7 years ago

Janatbek commented 7 years ago

capture

Janatbek commented 7 years ago

sorry let me setup better karma.

ArtemGovorov commented 7 years ago

Then I suggest to refactor your code a bit:

So that you have an equivalent of karma bootstrap file, like here:

Janatbek commented 7 years ago

inside files array?

ArtemGovorov commented 7 years ago

Like this:

ArtemGovorov commented 7 years ago

I'm not Karma expert, but hope you get the idea - you need the karmaTest.ts file to be executed before tests (so may just google how to do it in Karma if it doesn't work).

Janatbek commented 7 years ago

Uncaught SyntaxError: Unexpected token import at src/karmaTest.ts:1 sorry. I have to figure that out. thank you.

ArtemGovorov commented 7 years ago

You may need a preprocessor for the file (so that webpack compiles it with TypeScript):

Janatbek commented 7 years ago

Yep I added it there:

preprocessors: { '.js': ['sourcemap'], '.ts': ['sourcemap'], '*/.spec.ts': ['sourcemap', 'webpack'] },

ArtemGovorov commented 7 years ago

You have only added the webpack for **/*.spec.ts, not for the karmaTest.

Janatbek commented 7 years ago
// beforeAll( ()=> {
//     TestBed.initTestEnvironment(
//         BrowserDynamicTestingModule, platformBrowserDynamicTesting());
// });

Failed: Cannot read property 'injector' of null if I comment this line

ArtemGovorov commented 7 years ago

Try reverting the changes, and try this:

beforeAll(() => {
    TestBed.resetTestEnvironment(); // <--
    TestBed.initTestEnvironment(
        BrowserDynamicTestingModule,
        platformBrowserDynamicTesting()
    );
  })

Should hopefully work in both karma and wallaby.

ArtemGovorov commented 7 years ago

https://github.com/Janatbek/wallaby-playground/pull/5