Closed ArtemGovorov closed 7 years ago
sorry let me setup better karma.
Then I suggest to refactor your code a bit:
wallabyTest
,beforeAll
code,src/karmaTest.ts
file (with the same content as wallabyTest
),{ pattern: './src/karmaTest.ts', watched: false },
So that you have an equivalent of karma bootstrap file, like here:
inside files array?
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).
Uncaught SyntaxError: Unexpected token import at src/karmaTest.ts:1 sorry. I have to figure that out. thank you.
You may need a preprocessor for the file (so that webpack compiles it with TypeScript):
Yep I added it there:
preprocessors: { '.js': ['sourcemap'], '.ts': ['sourcemap'], '*/.spec.ts': ['sourcemap', 'webpack'] },
You have only added the webpack
for **/*.spec.ts
, not for the karmaTest
.
// beforeAll( ()=> {
// TestBed.initTestEnvironment(
// BrowserDynamicTestingModule, platformBrowserDynamicTesting());
// });
Failed: Cannot read property 'injector' of null if I comment this line
Try reverting the changes, and try this:
beforeAll(() => {
TestBed.resetTestEnvironment(); // <--
TestBed.initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
})
Should hopefully work in both karma and wallaby.