Jsonp Provider Error on Angular2 - web-services

I struggle http client works, firstly i tried http module but when i searched examples, I saw they did with jsonp. Briefly, when i tried this jsonp i get this error :
Error: Uncaught (in promise): Error: Error in ./MusteriComponent class MusteriComponent **- inline template:0:0 caused by: No provider for Jsonp!**
Stack trace:
resolvePromise#http://localhost:4200/main.bundle.js:101640:31
makeResolver/<#http://localhost:4200/main.bundle.js:101617:13
Zone$1</ZoneDelegate</ZoneDelegate.prototype.invoke#http://localhost:4200/main.bundle.js:101414:19
NgZoneImpl/this.inner<.onInvoke#http://localhost:4200/main.bundle.js:65487:28
Zone$1</ZoneDelegate</ZoneDelegate.prototype.invoke#http://localhost:4200/main.bundle.js:101413:19
Zone$1</Zone</Zone.prototype.run#http://localhost:4200/main.bundle.js:101307:24
scheduleResolveOrReject/<#http://localhost:4200/main.bundle.js:101673:52
Zone$1</ZoneDelegate</ZoneDelegate.prototype.invokeTask#http://localhost:4200/main.bundle.js:101447:23
NgZoneImpl/this.inner<.onInvokeTask#http://localhost:4200/main.bundle.js:65478:28
Zone$1</ZoneDelegate</ZoneDelegate.prototype.invokeTask#http://localhost:4200/main.bundle.js:101446:23
Zone$1</Zone</Zone.prototype.runTask#http://localhost:4200/main.bundle.js:101347:28
drainMicroTaskQueue#http://localhost:4200/main.bundle.js:101579:25
ZoneTask/this.invoke#http://localhost:4200/main.bundle.js:101519:25
app-module
import { BrowserModule } from '#angular/platform-browser';
import { NgModule } from '#angular/core';
import { FormsModule } from '#angular/forms';
import { HttpModule} from '#angular/http';
import { AppComponent } from './app.component';
import { MainModule } from './main/main.module'
import { routing,
appRoutingProviders } from './app.routing';
import { LoginComponent } from './login/login.component';
import {InMemoryWebApiModule} from "angular2-in-memory-web-api";
import {CosmoData} from "./cosmo-data"
#NgModule({
declarations: [
LoginComponent,
AppComponent
],
imports: [
MainModule,
BrowserModule,
FormsModule,
HttpModule,
routing,
InMemoryWebApiModule.forRoot(CosmoData)
],
providers: [
appRoutingProviders
],
bootstrap: [AppComponent]
})
export class AppModule { }
package-json
{
"name": "cosmo-client",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"#angular/common": "2.0.0",
"#angular/compiler": "2.0.0",
"#angular/core": "2.0.0",
"#angular/forms": "2.0.0",
"#angular/http": "2.0.0",
"#angular/platform-browser": "2.0.0",
"#angular/platform-browser-dynamic": "2.0.0",
"#angular/router": "3.0.0",
"angular2-in-memory-web-api": "0.0.20",
"core-js": "^2.4.1",
"primeng": "^1.0.0-beta.16",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.23"
},
"devDependencies": {
"#types/jasmine": "^2.2.30",
"angular-cli": "1.0.0-beta.14",
"codelyzer": "~0.0.26",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.5",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "2.0.2",
"webpack": "2.1.0-beta.22"
}
}
gib-service
import { Injectable } from '#angular/core';
import {Observable} from "rxjs";
import {Response,Http,Jsonp} from "#angular/http";
import any = jasmine.any;
#Injectable()
export class GibService {
constructor(private http:Http,private jsonp:Jsonp) { }
items:any;
private handleError(err) {
console.log(err);
return Observable.throw(err);
}
search ():Observable<any> {
return this.jsonp.get('http://gturnquist-quoters.cfapps.io/api/random')
.map(resp => resp.json()).catch(this.handleError);
}
}
MusteriTanimlama
import {Component, OnInit} from '#angular/core';
import {GibService} from "./gib.service";
import {MusteriTanimlama} from "./musteritanimlama";
import { Observable } from 'rxjs/Observable';
import any = jasmine.any;
#Component({
selector: 'cosmo-musteritanimlama',
templateUrl: './musteritanimlama.component.html',
styleUrls: ['./musteritanimlama.component.css'],
providers: [GibService]
})
export class MusteritanimlamaComponent {
constructor(private gibservice: GibService) {
}
search () {
this.gibservice.search().subscribe(m=>{
console.log("search");
console.log(m);
});
}
Thank you for answer

You need add the JsonpModule to imports:
#NgModule({
declarations: [
LoginComponent,
AppComponent
],
imports: [
MainModule,
BrowserModule,
FormsModule,
HttpModule,
JsonpModule, // <<<<===
routing,
InMemoryWebApiModule.forRoot(CosmoData)
],
providers: [
appRoutingProviders
],
bootstrap: [AppComponent]
})
export class AppModule { }

Related

TypeError: _reactNativeLanguages.default.addEventListener is not a function in Jest

I have completed my first react-native app. Now, I want to do unit testing and get code coverage for the whole application using jest. I have used npm packages like i18n-js, react-native-languages.
splash-test.js:
import React from 'react';
import Splash from '../Src/components/authentication/Splash';
import renderer from 'react-test-renderer';
test('renders correctly',()=>{
const tree = renderer.create(
<Splash />
).toJSON();
expect(tree).toMatchSnapshot();
})
env.js:
jest.mock('react-native-languages', () => ({
RNLanguages: {
language: 'en',
languages: ['en'],
},
}));
package.json:
{
"name": "app-name",
"version": "1.0.4",
"private": true,
"rnpm": {
"assets": [
"Src/assets/fonts/"
]
},
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest --coverage --coverageDirectory=output/coverage/jest"
},
"dependencies": {
"i18n-js": "^3.1.0",
"react": "16.6.3",
"react-native": "0.57.8",
"react-native-fast-image-zoom-viewer": "^2.3.0",
"react-native-firebase": "^5.1.1",
"react-native-gifted-chat": "^0.7.2",
"react-native-image-crop-picker": "^0.21.3",
"react-native-image-zoom-viewer": "^2.2.25",
"react-native-languages": "^3.0.1",
"react-native-material-dropdown": "^0.11.1",
"react-native-modal": "^7.0.2",
"react-native-permissions": "^1.1.1",
"react-native-progress": "^3.5.0",
"react-native-restart": "0.0.9",
"react-native-spinkit": "^1.1.1",
"react-native-swiper": "^1.5.14",
"react-native-view-toast": "0.0.1",
"react-navigation": "^3.0.8",
"react-redux": "^6.0.0",
"realm": "^2.22.0",
"redux": "^4.0.1",
"redux-thunk": "^2.3.0",
"rn-fetch-blob": "^0.10.15",
"tipsi-stripe": "^7.1.0"
},
"devDependencies": {
"babel-jest": "^23.6.0",
"jest": "^23.6.0",
"jest-junit": "^6.2.1",
"metro-react-native-babel-preset": "^0.51.0",
"react-test-renderer": "^16.6.3"
},
"jest": {
"preset": "react-native",
"transform": {
"^.+\\.(js)$": "<rootDir>/node_modules/react-native/jest/preprocessor.js"
},
"setupFiles": [
"./test/env.js"
],
"coverageReporters": [
"text"
],
"reporters": [
"default",
"jest-junit"
],
"collectCoverageFrom": [
"Src/**/*.{js,jsx}",
"!/node_modules/"
],
"transformIgnorePatterns": [
"node_modules/(?!(react-native|react-native-languages)/)"
]
},
"jest-junit": {
"output": "output/coverage/junit/junit.xml",
"usePathForSuiteName": "true"
}
}
Now, If i give npm test it throws an error as i mentioned in title. Someone tell me how to bypass all the npm modules i have used in the app.
Thanks in advance!

"TypeError: Cannot read property 'nav' of undefined" in Ionic

I raised a similar question two days back, but this time I am getting the same error when I run the code in an actual device or simulator. On a regular browser it works fine.
Here is my app.component.ts code:
import { Component, ViewChild } from '#angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '#ionic-native/status-bar';
import { SplashScreen } from '#ionic-native/splash-screen';
import { HomePage } from '../pages/home/home';
import { LoginPage } from '../pages/login/login';
import {NativeStorage} from '#ionic-native/native-storage';
import { NavController } from 'ionic-angular';
#Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage:any = LoginPage;
#ViewChild('navApp') nav : NavController;
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, private nativeStorage: NativeStorage,) {
platform.ready().then(() => {
this.nativeStorage.getItem('userExists').then((data)=>{
this.nav.push(HomePage);
console.log(data.userExists);
},(error)=>{
console.log("No Data in Local Storage");
this.nav.push(LoginPage);
})
statusBar.styleDefault();
splashScreen.hide();
});
}
}
This is my app.html
<ion-nav #navApp [root]="rootPage"></ion-nav>
This is my version info
global packages:
#ionic/cli-utils : 1.2.0
Cordova CLI : 7.0.1
Ionic CLI : 3.2.0
local packages:
#ionic/app-scripts : 1.3.7
#ionic/cli-plugin-cordova : 1.2.1
#ionic/cli-plugin-ionic-angular : 1.2.0
Cordova Platforms : android 6.2.3
Ionic Framework : ionic-angular 3.2.1
System:
Node : v6.10.2
OS : Windows 10
Xcode : not installed
ios-deploy : not installed
ios-sim : not installed
Package.json:
{
"name": "myapp",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"#angular/common": "4.1.0",
"#angular/compiler": "4.1.0",
"#angular/compiler-cli": "4.1.0",
"#angular/core": "4.1.0",
"#angular/forms": "4.1.0",
"#angular/http": "4.1.0",
"#angular/platform-browser": "4.1.0",
"#angular/platform-browser-dynamic": "4.1.0",
"#ionic-native/core": "3.7.0",
"#ionic-native/facebook": "^3.10.2",
"#ionic-native/native-storage": "^3.10.3",
"#ionic-native/splash-screen": "3.7.0",
"#ionic-native/status-bar": "3.7.0",
"#ionic/storage": "2.0.1",
"cordova-android": "^6.2.3",
"cordova-plugin-console": "^1.0.5",
"cordova-plugin-device": "^1.1.4",
"cordova-plugin-facebook4": "^1.9.0",
"cordova-plugin-nativestorage": "^2.2.2",
"cordova-plugin-splashscreen": "^4.0.3",
"cordova-plugin-statusbar": "^2.2.2",
"cordova-plugin-whitelist": "^1.3.1",
"ionic-angular": "3.2.1",
"ionic-native": "^2.5.1",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
"rxjs": "5.1.1",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.10"
},
"devDependencies": {
"#ionic/app-scripts": "1.3.7",
"#ionic/cli-plugin-cordova": "^1.2.1",
"#ionic/cli-plugin-ionic-angular": "^1.2.0",
"typescript": "2.2.1"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-console": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-whitelist": {},
"ionic-plugin-keyboard": {},
"cordova-plugin-facebook4": {
"APP_ID": "305938313175123",
"APP_NAME": "myapp"
},
"cordova-plugin-nativestorage": {}
},
"platforms": [
"android"
]
}
}
Updating to the latest ionic release 3.3.0 solved the issue!
Why dont you just change the value of rootPage instead of making a push?
You have the variable
rootPage:any = LoginPage;
So by default your homepage will be LoginPage. When you check in your localstorage if the nickname exists, instead of pushing a page, use
this.rootPage = NameofYourPageHere.
That should work.

Runtime Error Cannot find module "ionic-native" IONIC 2

I have been trying to add banner ads for the new ionic 2 apps but It display bellow error. i am doing it as shown here tutorial. but when i run it from browser using ionic serve -l -c its showing Runtime Error Cannot find module "ionic-native" error as bellow,
here is myapp.component.ts files code
import { Component } from '#angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '#ionic-native/status-bar';
import { SplashScreen } from '#ionic-native/splash-screen';
import { Geolocation } from '#ionic-native/geolocation';
import { AdMob } from 'ionic-native';
import { HomePage } from '../pages/home/home';
import { DetailsPage } from '../pages/details/details';
import { SettingModalPage } from '..Pages/setting-modal/setting-
modal';
#Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage:any = HomePage;
constructor(platform: Platform, statusBar: StatusBar, splashScreen:
SplashScreen) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
let options = {
adId: 'ca-app-pub-5732334124058455/7973166445',
adSize: 'SMART_BANNER',
isTesting: false
};
AdMob.createBanner(options).then(() => {
AdMob.showBanner(8);
});
});
}
}
in my package.json file,
"dependencies": {
"#angular/common": "2.4.8",
"#angular/compiler": "2.4.8",
"#angular/compiler-cli": "2.4.8",
"#angular/core": "2.4.8",
"#angular/forms": "2.4.8",
"#angular/http": "2.4.8",
"#angular/platform-browser": "2.4.8",
"#angular/platform-browser-dynamic": "2.4.8",
"#angular/platform-server": "2.4.8",
"#ionic-native/admob": "^3.4.4",
"#ionic-native/core": "^3.1.0",
"#ionic-native/geolocation": "^3.4.4",
"#ionic-native/launch-navigator": "^3.4.4",
"#ionic-native/splash-screen": "3.1.0",
"#ionic-native/status-bar": "3.1.0",
"#ionic/storage": "2.0.0",
"font-awesome": "^4.7.0",
"ionic-angular": "2.3.0",
"ionic2-rating": "^1.2.0",
"ionicons": "3.0.0",
"rxjs": "5.0.1",
"sw-toolbox": "3.4.0",
"zone.js": "0.7.2"
},
"devDependencies": {
"#ionic/app-scripts": "1.1.4",
"typescript": "2.0.9"
},
"cordovaPlugins": [
"cordova-plugin-whitelist",
"cordova-plugin-console",
"cordova-plugin-statusbar",
"cordova-plugin-device",
"cordova-plugin-splashscreen",
"ionic-plugin-keyboard"
],
Check here.
import { AdMob } from 'ionic-native';
was in ionic-native 2.x.
Do:
ionic plugin add cordova-plugin-admobpro --save
npm install --save #ionic-native/admob
And:
import { AdMob, AdMobOptions, AdSize, AdExtras} from '#ionic-native/admob';//import
constructor(platform: Platform, statusBar: StatusBar, splashScreen:
SplashScreen,admob:Admob)//inject in constructor.
//and use
let options:AdMobOptions={
adId: 'ca-app-pub-5732334124058455/7973166445',
adSize: 'SMART_BANNER',
isTesting: false
}
this.admob.createBanner(options).then(()=>{
this.admob.showBanner(8)
})
The package ionic-native doesn't exist anymore. The modules are now in its own package, so you need to change:
import { AdMob } from 'ionic-native';
from
import { AdMob } from '#ionic-native/admob';

Angular2 2.4.3 with Angular-CLI 1.0.0-beta.25.5, after upgrade unit tests with karma/jasmine stops working

Recently I updated Angular from 2.0.3 to 2.4.3 and Angular-CLI from 1.0.0-beta.21 to 1.0.0-beta.25.5
After upgrade my unit tests stop working. Below you can find test file, configuration files and test results. Do you have any idea what can be wrong with it? Thanks
test result
$ npm test -- --watch=false
> portal#0.0.0 test /Users/artur/Sites/portal
> ng test "--watch=false"
19 01 2017 08:22:52.703:WARN [karma]: Port 9879 in use
19 01 2017 08:22:52.705:INFO [karma]: Karma v1.4.0 server started at http://0.0.0.0:9880/
19 01 2017 08:22:52.705:INFO [launcher]: Launching browser Chrome with unlimited concurrency
19 01 2017 08:22:52.726:INFO [launcher]: Starting browser Chrome
19 01 2017 08:22:55.619:INFO [Chrome 55.0.2883 (Mac OS X 10.12.2)]: Connected on socket XIi2HWa92rY4uvNvAAAA with id 35735618
Chrome 55.0.2883 (Mac OS X 10.12.2): Executed 0 of 0 ERROR (0.004 secs / 0 secs)
npm ERR! Test failed. See above for more details.
banner.component.spec.ts
/* tslint:disable:no-unused-variable */
import { Component } from '#angular/core';
import { TestBed, async } from '#angular/core/testing';
import { BannerComponent } from './banner.component';
import { RouterTestingModule } from '#angular/router/testing';
#Component({
template: ''
})
class DummyComponent {}
describe('Component: Banner', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
DummyComponent,
BannerComponent
],
imports: [
RouterTestingModule.withRoutes([
{ path: '', component: DummyComponent }
])
],
providers: []
});
});
it('should create an instance', async(() => {
let fixture = TestBed.createComponent(BannerComponent);
let component = fixture.debugElement.componentInstance;
expect(component).toBeTruthy();
}));
});
banner.component.ts
import { Component, OnInit } from '#angular/core';
#Component({
selector: 'app-banner',
templateUrl: './banner.component.html',
styleUrls: ['./banner.component.scss'],
styles: [".banner >>> lp-svg svg path { fill: #fcfcfc; }"]
})
export class BannerComponent {}
package.json
{
"name": "portal",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ngc": "./node_modules/.bin/ngc -p ./src",
"start": "./node_modules/.bin/ng serve --host 0.0.0.0 --port 4000",
"build.dev": "./node_modules/.bin/ng build --bh /portal/",
"build.dev.watch": "./node_modules/.bin/ng build --bh /portal/ --watch true",
"build.prod": "./node_modules/.bin/ng build --bh /portal/ --prod --env=prod",
"build.prod.watch": "./node_modules/.bin/ng build --bh /portal/ --prod --env=prod",
"serve.prod": "node lp-server.js",
"lint": "tslint \"src/**/*.ts\"",
"test": "./node_modules/.bin/ng test",
"e2e": "./protractor.sh",
"copy.support-page": "./node_modules/.bin/copyfiles -u 1 ./src/support.html ./dist"
},
"private": true,
"dependencies": {
"#angular/common": "^2.4.3",
"#angular/compiler": "^2.4.3",
"#angular/compiler-cli": "^2.4.3",
"#angular/core": "^2.4.3",
"#angular/forms": "^2.4.3",
"#angular/http": "^2.4.3",
"#angular/platform-browser": "^2.4.3",
"#angular/platform-browser-dynamic": "^2.4.3",
"#angular/platform-server": "^2.4.3",
"#angular/router": "^3.4.3",
"copyfiles": "1.0.0",
"core-js": "2.4.1",
"jquery": "2.2.3",
"perfect-scrollbar": "~0.6.10",
"rxjs": "^5.0.3",
"ts-helpers": "1.1.1",
"typescript": "2.0.2",
"underscore": "1.8.3",
"zone.js": "0.6.23"
},
"devDependencies": {
"#types/jasmine": "^2.5.41",
"angular-cli": "^1.0.0-beta.25.5",
"codelyzer": "^2.0.0-beta.4",
"jasmine-core": "^2.5.2",
"jasmine-spec-reporter": "^3.2.0",
"karma": "^1.4.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.1.0",
"karma-mocha-reporter": "^2.2.1",
"karma-phantomjs-launcher": "^1.0.2",
"karma-remap-istanbul": "^0.4.0",
"live-server": "1.1.0",
"protractor": "^5.0.0",
"ts-node": "1.2.1",
"tslint": "3.13.0"
}
}
karma.conf.js
// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', 'angular-cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-phantomjs-launcher'),
require('karma-remap-istanbul'),
require('angular-cli/plugins/karma'),
require('karma-mocha-reporter')
],
files: [
{ pattern: 'src/test.ts', watched: false },
{ pattern: 'src/assets/img/*', watched: false, included: false, served: true, nocache: false }
],
proxies: {
'/portal/assets/img/': '/base/src/assets/img/'
},
preprocessors: {
'./src/test.ts': ['angular-cli']
},
remapIstanbulReporter: {
reports: {
html: 'coverage',
lcovonly: './coverage/coverage.lcov'
}
},
angularCli: {
config: './angular-cli.json',
environment: 'dev'
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'karma-remap-istanbul']
: ['progress'],
port: 9879,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
browserConsoleLogOptions: {
level: 'debug',
format: '%b %T: %m',
terminal: true
},
customLaunchers: {
'PhantomJS_custom': {
base: 'PhantomJS',
options: {
windowName: 'my-window',
settings: {
webSecurityEnabled: false
},
},
flags: ['--load-images=true'],
debug: true
}
},
phantomjsLauncher: {
// Have phantomjs exit if a ResourceError is encountered (useful if karma exits without killing phantom)
exitOnResourceError: true
}
});
};
angular-cli.json
{
"project": {
"version": "1.0.0-beta.25.5",
"name": "ui-lender-portal-v2"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": ["assets"],
"index": "index.html",
"main": "main.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"prefix": "lp",
"mobile": false,
"styles": [
"styles.scss",
"../node_modules/perfect-scrollbar/dist/css/perfect-scrollbar.min.css"
],
"scripts": [
"../node_modules/underscore/underscore.js",
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/perfect-scrollbar/dist/js/perfect-scrollbar.js",
"./libs/jquery-ui/jquery-ui.min.js",
"./libs/jquery-mobile/jquery.mobile.custom.min.js",
"./libs/slick/slick.js"
],
"environments": {
"source": "environments/environment.ts",
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"addons": [],
"packages": [],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "scss",
"prefixInterfaces": false,
"inline": {
"style": false,
"template": false
},
"spec": {
"class": false,
"component": true,
"directive": true,
"module": false,
"pipe": true,
"service": true
}
}
}
Finally I created new project with Angular-CLI and copied source files from my project. This helps.

Angular 2 unit test for NgModule class

Wanted to know if there is any way to make NgModule class unit testable.
If yes want can we expect in test case it block.
import { NgModule } from '#angular/core';
import { BrowserModule } from '#angular/platform-browser';
import
{ AppComponent } from './app.component';
#NgModule({
imports: [ BrowserModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }