MSX common components and testing mocks
npm install @cisco-msx/commonCommon components and directives for MSX platform and service packs. Also
contains mock testing versions of those components and directives that can be
used safely outside of an AngularJS environment.
``typescript
import { NgModule } from '@angular/core';
import { MsxCommonModule } from '@cisco-msx/common';
@NgModule({
imports: [
MsxCommonModule
]
})
export class MyModule {}
`
For service packs, ensure you have installed and are using
@cisco-msx/webpack-externals in your Webpack configuration, and add@cisco-msx/common to your package.json's peerDependencies anddevDependencies. This ensures that your package indicates that it depends on@cisco-msx/common to run, but will install the package locally during
development for use in your unit tests.
`json`
{
"name": "my-service-pack",
"peerDependencies": {
"@cisco-msx/common": "^1.0.0"
},
"devDependencies": {
"@cisco-msx/common": "^1.0.0"
}
}
If you are testing your component using Angular's TestBed, import theMsxCommonTestingModule in your testing module instead of MsxCommonModule to@cisco-msx/common
have 's components and directives mocked.
`typescript
import {
async,
ComponentFixture,
TestBed
} from '@angular/core/testing';
import { MsxCommonTestingModule } from '@cisco-msx/common/testing';
import { MyComponent } from './my.component';
describe('MyComponent', () => {
let component: MyComponent;
let fixture: ComponentFixture
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
MsxCommonTestingModule
],
declarations: [MyComponent]
});
fixture = TestBed.createComponent(MyComponent);
component = fixture.componentInstance;
}));
});
``