Many Angular 2 cli applications come with karma-jasmine tests already set up.
If you decide to enhance your tests by using typemoq, simply run the command npm install typemoq --save-dev
Then, include typemoq in one of your test files like this:
import * as Moq from 'typemoq';
...
it('pointless test is pointless', async(() => {
let carMock = Moq.Mock.ofInstance(Car);
}));
class Car { ... }
However, after adding typemoq, some users have reported encountering the following error when running their tests. Have you faced a similar issue while working with typemoq in angular-cli projects or while adding dependencies to angular-cli projects?
TypeError: Cannot read property 'substr' of undefined at Function. (C:\Source\ng-example-app\foo\node_modules\webpack-sources\node_modules\source-map\lib\source-node.js:115:26)