├── .angular-cli.json ├── .angulardoc.json ├── .editorconfig ├── .gitignore ├── .prettierrc ├── README.md ├── apps ├── .gitkeep ├── app1 │ ├── e2e │ │ ├── app.e2e-spec.ts │ │ ├── app.po.ts │ │ └── tsconfig.e2e.json │ └── src │ │ ├── app │ │ ├── +state │ │ │ ├── app.actions.ts │ │ │ ├── app.effects.spec.ts │ │ │ ├── app.effects.ts │ │ │ ├── app.init.ts │ │ │ ├── app.interfaces.ts │ │ │ ├── app.reducer.spec.ts │ │ │ └── app.reducer.ts │ │ ├── app-routing.module.ts │ │ ├── app.component.css │ │ ├── app.component.html │ │ ├── app.component.spec.ts │ │ ├── app.component.ts │ │ ├── app.module.ts │ │ ├── core │ │ │ ├── core-routing.module.ts │ │ │ ├── core.component.css │ │ │ ├── core.component.html │ │ │ ├── core.component.spec.ts │ │ │ ├── core.component.ts │ │ │ └── core.module.ts │ │ ├── feature1 │ │ │ ├── feature1.component.css │ │ │ ├── feature1.component.html │ │ │ ├── feature1.component.spec.ts │ │ │ ├── feature1.component.ts │ │ │ └── feature1.module.ts │ │ ├── feature2 │ │ │ ├── feature2.component.css │ │ │ ├── feature2.component.html │ │ │ ├── feature2.component.spec.ts │ │ │ ├── feature2.component.ts │ │ │ └── feature2.module.ts │ │ ├── feature3 │ │ │ ├── feature3.component.css │ │ │ ├── feature3.component.html │ │ │ ├── feature3.component.spec.ts │ │ │ ├── feature3.component.ts │ │ │ └── feature3.module.ts │ │ └── services │ │ │ └── index.ts │ │ ├── assets │ │ ├── .gitkeep │ │ └── nx-logo.png │ │ ├── environments │ │ ├── environment.prod.ts │ │ └── environment.ts │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── main.ts │ │ ├── polyfills.ts │ │ ├── styles.scss │ │ └── tsconfig.app.json └── app2 │ ├── e2e │ ├── app.e2e-spec.ts │ ├── app.po.ts │ └── tsconfig.e2e.json │ └── src │ ├── app │ ├── app.component.css │ ├── app.component.html │ ├── app.component.spec.ts │ ├── app.component.ts │ └── app.module.ts │ ├── assets │ ├── .gitkeep │ └── nx-logo.png │ ├── environments │ ├── environment.prod.ts │ └── environment.ts │ ├── favicon.ico │ ├── index.html │ ├── main.ts │ ├── polyfills.ts │ ├── styles.css │ └── tsconfig.app.json ├── jest ├── jestGlobalMocks.ts └── setupJest.ts ├── karma.conf.js ├── libs ├── .gitkeep ├── http-service │ ├── index.ts │ └── src │ │ ├── http-client.service.spec.ts │ │ ├── http-client.service.ts │ │ ├── http-service.module.spec.ts │ │ ├── http-service.module.ts │ │ ├── http-service.tokens.ts │ │ ├── http-service.ts │ │ ├── simple-http.service.spec.ts │ │ └── simple-http.service.ts ├── not-found │ ├── index.ts │ └── src │ │ ├── not-found.module.spec.ts │ │ ├── not-found.module.ts │ │ └── not-found │ │ ├── not-found.component.css │ │ ├── not-found.component.html │ │ ├── not-found.component.spec.ts │ │ └── not-found.component.ts ├── session-resolver │ ├── index.ts │ └── src │ │ ├── session-resolver.spec.ts │ │ └── session-resolver.ts ├── stringutils │ ├── index.ts │ └── src │ │ ├── stringutils.spec.ts │ │ └── stringutils.ts └── tab-nav │ ├── index.ts │ └── src │ ├── models │ └── tab.model.ts │ ├── tab-nav.module.spec.ts │ ├── tab-nav.module.ts │ └── tab-nav │ ├── tab-nav.component.html │ ├── tab-nav.component.scss │ ├── tab-nav.component.spec.ts │ └── tab-nav.component.ts ├── package-lock.json ├── package.json ├── protractor.conf.js ├── test.js ├── tools ├── schematics │ └── .gitkeep └── tsconfig.tools.json ├── tsconfig.json ├── tsconfig.spec.json ├── tslint.json ├── yarn-error.log └── yarn.lock /.angular-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@nrwl/schematics/src/schema.json", 3 | "project": { 4 | "name": "nx-demo-jest", 5 | "npmScope": "nx-demo-jest", 6 | "latestMigration": "20180424-add-tsconfig-tools" 7 | }, 8 | "apps": [ 9 | { 10 | "name": "app1", 11 | "root": "apps/app1/src", 12 | "outDir": "dist/apps/app1", 13 | "assets": [ 14 | "assets", 15 | "favicon.ico" 16 | ], 17 | "index": "index.html", 18 | "main": "main.ts", 19 | "polyfills": "polyfills.ts", 20 | "test": "../../../test.js", 21 | "tsconfig": "tsconfig.app.json", 22 | "testTsconfig": "../../../tsconfig.spec.json", 23 | "prefix": "app", 24 | "styles": [ 25 | "../../../node_modules/bootstrap/dist/css/bootstrap.css", 26 | "styles.scss" 27 | ], 28 | "scripts": [], 29 | "environmentSource": "environments/environment.ts", 30 | "environments": { 31 | "dev": "environments/environment.ts", 32 | "prod": "environments/environment.prod.ts" 33 | }, 34 | "tags": [] 35 | }, 36 | { 37 | "name": "app2", 38 | "root": "apps/app2/src", 39 | "outDir": "dist/apps/app2", 40 | "assets": [ 41 | "assets", 42 | "favicon.ico" 43 | ], 44 | "index": "index.html", 45 | "main": "main.ts", 46 | "polyfills": "polyfills.ts", 47 | "test": "../../../test.js", 48 | "tsconfig": "tsconfig.app.json", 49 | "testTsconfig": "../../../tsconfig.spec.json", 50 | "prefix": "app", 51 | "styles": [ 52 | "styles.css" 53 | ], 54 | "scripts": [], 55 | "environmentSource": "environments/environment.ts", 56 | "environments": { 57 | "dev": "environments/environment.ts", 58 | "prod": "environments/environment.prod.ts" 59 | }, 60 | "tags": [] 61 | }, 62 | { 63 | "name": "http-service", 64 | "root": "libs/http-service/src", 65 | "test": "../../../test.js", 66 | "appRoot": "", 67 | "tags": [] 68 | }, 69 | { 70 | "name": "not-found", 71 | "root": "libs/not-found/src", 72 | "test": "../../../test.js", 73 | "appRoot": "", 74 | "tags": [] 75 | }, 76 | { 77 | "name": "session-resolver", 78 | "root": "libs/session-resolver/src", 79 | "test": "../../../test.js", 80 | "appRoot": "", 81 | "tags": [] 82 | }, 83 | { 84 | "name": "stringutils", 85 | "root": "libs/stringutils/src", 86 | "test": "../../../test.js", 87 | "appRoot": "", 88 | "tags": [] 89 | }, 90 | { 91 | "name": "tab-nav", 92 | "root": "libs/tab-nav/src", 93 | "test": "../../../test.js", 94 | "appRoot": "", 95 | "tags": [] 96 | } 97 | ], 98 | "e2e": { 99 | "protractor": { 100 | "config": "./protractor.conf.js" 101 | } 102 | }, 103 | "lint": [ 104 | { 105 | "project": "./tsconfig.spec.json", 106 | "exclude": "**/node_modules/**" 107 | }, 108 | { 109 | "project": "apps/app1/src/tsconfig.app.json", 110 | "exclude": "**/node_modules/**" 111 | }, 112 | { 113 | "project": "apps/app1/e2e/tsconfig.e2e.json", 114 | "exclude": "**/node_modules/**" 115 | }, 116 | { 117 | "project": "apps/app2/src/tsconfig.app.json", 118 | "exclude": "**/node_modules/**" 119 | }, 120 | { 121 | "project": "apps/app2/e2e/tsconfig.e2e.json", 122 | "exclude": "**/node_modules/**" 123 | } 124 | ], 125 | "test": { 126 | "karma": { 127 | "config": "./karma.conf.js" 128 | } 129 | }, 130 | "defaults": { 131 | "schematics": { 132 | "collection": "@nrwl/schematics", 133 | "postGenerate": "npm run format", 134 | "newProject": [ 135 | "app", 136 | "lib" 137 | ] 138 | }, 139 | "styleExt": "css", 140 | "component": {} 141 | }, 142 | "warnings": { 143 | "typescriptMismatch": false 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /.angulardoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "repoId": "b562871e-5c6a-4f90-9298-1041a5244200", 3 | "lastSync": 0 4 | } -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | 8 | # dependencies 9 | /node_modules 10 | 11 | # IDEs and editors 12 | /.idea 13 | .project 14 | .classpath 15 | .c9/ 16 | *.launch 17 | .settings/ 18 | *.sublime-workspace 19 | 20 | # IDE - VSCode 21 | .vscode/* 22 | !.vscode/settings.json 23 | !.vscode/tasks.json 24 | !.vscode/launch.json 25 | !.vscode/extensions.json 26 | 27 | # misc 28 | /.sass-cache 29 | /connect.lock 30 | /coverage 31 | /libpeerconnection.log 32 | npm-debug.log 33 | testem.log 34 | /typings 35 | 36 | # e2e 37 | /e2e/*.js 38 | /e2e/*.map 39 | 40 | # System Files 41 | .DS_Store 42 | Thumbs.db 43 | .npmrc 44 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "printWidth": 120 4 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NxDemoJest 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.5.0 using [Nrwl Nx](https://nrwl.io/nx). 4 | 5 | ## Nrwl Extensions for Angular (Nx) 6 | 7 | 8 | 9 | Nx is an open source toolkit for enterprise Angular applications. 10 | 11 | Nx is designed to help you create and build enterprise grade Angular applications. It provides an opinionated approach to application project structure and patterns. 12 | 13 | ## Quick Start & Documentation 14 | 15 | [Watch a 5-minute video on how to get started with Nx.](http://nrwl.io/nx) 16 | 17 | ## Generate your first application 18 | 19 | Run `ng generate app myapp` to generate an application. When using Nx, you can create multiple applications and libraries in the same CLI workspace. Read more [here](http://nrwl.io/nx). 20 | 21 | ## Development server 22 | 23 | Run `ng serve --app=myapp` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 24 | 25 | ## Code scaffolding 26 | 27 | Run `ng generate component component-name --app=myapp` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 28 | 29 | ## Build 30 | 31 | Run `ng build --app=myapp` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build. 32 | 33 | ## Running unit tests 34 | 35 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 36 | 37 | ## Running end-to-end tests 38 | 39 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 40 | Before running the tests make sure you are serving the app via `ng serve`. 41 | 42 | ## Further help 43 | 44 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). 45 | -------------------------------------------------------------------------------- /apps/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /apps/app1/e2e/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | 3 | describe('app1 App', () => { 4 | let page: AppPage; 5 | 6 | beforeEach(() => { 7 | page = new AppPage(); 8 | }); 9 | 10 | it('should display welcome message', () => { 11 | page.navigateTo(); 12 | expect(page.text()).toContain('Welcome'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /apps/app1/e2e/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | text() { 9 | return browser.findElement(by.css('body')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /apps/app1/e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../../dist/out-tsc/e2e/app1", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | }, 13 | "include": [ 14 | "../**/*.ts" 15 | /* add all lazy-loaded libraries here: "../../../libs/my-lib/index.ts" */ 16 | 17 | , "../../../libs/not-found/index.ts" 18 | ], 19 | "exclude": [ 20 | "**/*.spec.ts" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /apps/app1/src/app/+state/app.actions.ts: -------------------------------------------------------------------------------- 1 | export interface LoadData { 2 | type: 'LOAD_DATA'; 3 | payload: {}; 4 | } 5 | 6 | export interface DataLoaded { 7 | type: 'DATA_LOADED'; 8 | payload: {}; 9 | } 10 | 11 | export type AppAction = LoadData | DataLoaded; 12 | -------------------------------------------------------------------------------- /apps/app1/src/app/+state/app.effects.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | import { StoreModule } from '@ngrx/store'; 3 | import { Actions } from '@ngrx/effects'; 4 | import { provideMockActions } from '@ngrx/effects/testing'; 5 | import { DataPersistence } from '@nrwl/nx'; 6 | import { readAll, hot } from '@nrwl/nx/testing'; 7 | import { AppEffects } from './app.effects'; 8 | import { of } from 'rxjs/observable/of'; 9 | import { marbles } from 'rxjs-marbles'; 10 | 11 | describe('AppEffects', () => { 12 | let actions; 13 | let effects: AppEffects; 14 | 15 | beforeEach(() => { 16 | TestBed.configureTestingModule({ 17 | imports: [StoreModule.forRoot({})], 18 | providers: [AppEffects, DataPersistence, provideMockActions(() => actions)] 19 | }); 20 | 21 | effects = TestBed.get(AppEffects); 22 | }); 23 | 24 | describe('someEffect', () => { 25 | it( 26 | 'should work', 27 | marbles(async m => { 28 | actions = hot('-a-|', { a: { type: 'LOAD_DATA' } }); 29 | expect(await readAll(effects.loadData)).toEqual([{ type: 'DATA_LOADED', payload: {} }]); 30 | }) 31 | ); 32 | }); 33 | 34 | describe('someEffect', () => { 35 | it( 36 | 'should work with m.hot', 37 | marbles(async m => { 38 | actions = m.hot('-a-|', { a: { type: 'LOAD_DATA' } }); 39 | expect(await readAll(effects.loadData)).toEqual([{ type: 'DATA_LOADED', payload: {} }]); 40 | }) 41 | ); 42 | }); 43 | }); 44 | -------------------------------------------------------------------------------- /apps/app1/src/app/+state/app.effects.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { Effect, Actions } from '@ngrx/effects'; 3 | import { DataPersistence } from '@nrwl/nx'; 4 | import { of } from 'rxjs/observable/of'; 5 | import 'rxjs/add/operator/switchMap'; 6 | import { AppState } from './app.interfaces'; 7 | import { LoadData, DataLoaded } from './app.actions'; 8 | 9 | @Injectable() 10 | export class AppEffects { 11 | @Effect() 12 | loadData = this.dataPersistence.fetch('LOAD_DATA', { 13 | run: (action: LoadData, state: AppState) => { 14 | return { 15 | type: 'DATA_LOADED', 16 | payload: {} 17 | }; 18 | }, 19 | 20 | onError: (action: LoadData, error) => { 21 | console.error('Error', error); 22 | } 23 | }); 24 | 25 | constructor(private actions: Actions, private dataPersistence: DataPersistence) {} 26 | } 27 | -------------------------------------------------------------------------------- /apps/app1/src/app/+state/app.init.ts: -------------------------------------------------------------------------------- 1 | import { App } from './app.interfaces'; 2 | 3 | export const appInitialState: App = { 4 | // fill it initial state here 5 | }; 6 | -------------------------------------------------------------------------------- /apps/app1/src/app/+state/app.interfaces.ts: -------------------------------------------------------------------------------- 1 | export interface App { 2 | // define state here 3 | } 4 | 5 | export interface AppState { 6 | readonly app: App; 7 | } 8 | -------------------------------------------------------------------------------- /apps/app1/src/app/+state/app.reducer.spec.ts: -------------------------------------------------------------------------------- 1 | import { appReducer } from './app.reducer'; 2 | import { appInitialState } from './app.init'; 3 | import { App } from './app.interfaces'; 4 | import { DataLoaded } from './app.actions'; 5 | 6 | describe('appReducer', () => { 7 | it('should work', () => { 8 | const state: App = {}; 9 | const action: DataLoaded = { type: 'DATA_LOADED', payload: {} }; 10 | const actual = appReducer(state, action); 11 | expect(actual).toEqual({}); 12 | }); 13 | }); 14 | -------------------------------------------------------------------------------- /apps/app1/src/app/+state/app.reducer.ts: -------------------------------------------------------------------------------- 1 | import { App } from './app.interfaces'; 2 | import { AppAction } from './app.actions'; 3 | 4 | export function appReducer(state: App, action: AppAction): App { 5 | switch (action.type) { 6 | case 'DATA_LOADED': { 7 | return { ...state, ...action.payload }; 8 | } 9 | default: { 10 | return state; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /apps/app1/src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Route, RouterModule } from '@angular/router'; 3 | 4 | import { CoreModule } from './core/core.module'; 5 | import { Feature3Component } from './feature3/feature3.component'; 6 | import { Feature3Module } from './feature3/feature3.module'; 7 | 8 | const routes: Route[] = [{ path: 'f3', component: Feature3Component }]; 9 | @NgModule({ 10 | imports: [RouterModule.forRoot(routes), CoreModule, Feature3Module], 11 | exports: [RouterModule] 12 | }) 13 | export class AppRoutingModule {} 14 | -------------------------------------------------------------------------------- /apps/app1/src/app/app.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dereklin/nx-demo-jest/68c05805cc505596680337c4afce8b7c588a9f49/apps/app1/src/app/app.component.css -------------------------------------------------------------------------------- /apps/app1/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /apps/app1/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { AppComponent } from './app.component'; 4 | import { RouterTestingModule } from '@angular/router/testing'; 5 | 6 | describe('AppComponent', () => { 7 | let component: AppComponent; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach( 11 | async(() => { 12 | TestBed.configureTestingModule({ 13 | imports: [RouterTestingModule], 14 | declarations: [AppComponent] 15 | }).compileComponents(); 16 | }) 17 | ); 18 | 19 | beforeEach(() => { 20 | fixture = TestBed.createComponent(AppComponent); 21 | component = fixture.componentInstance; 22 | fixture.detectChanges(); 23 | }); 24 | 25 | it('should create', () => { 26 | expect(component).toBeTruthy(); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /apps/app1/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.css'] 7 | }) 8 | export class AppComponent implements OnInit { 9 | constructor() {} 10 | 11 | ngOnInit() {} 12 | } 13 | -------------------------------------------------------------------------------- /apps/app1/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { AppComponent } from './app.component'; 3 | import { BrowserModule } from '@angular/platform-browser'; 4 | import { NxModule } from '@nrwl/nx'; 5 | import { RouterModule } from '@angular/router'; 6 | import { StoreModule } from '@ngrx/store'; 7 | import { EffectsModule } from '@ngrx/effects'; 8 | import { appReducer } from './+state/app.reducer'; 9 | import { appInitialState } from './+state/app.init'; 10 | import { AppEffects } from './+state/app.effects'; 11 | import { StoreDevtoolsModule } from '@ngrx/store-devtools'; 12 | import { environment } from '../environments/environment'; 13 | import { StoreRouterConnectingModule } from '@ngrx/router-store'; 14 | import { AppRoutingModule } from './app-routing.module'; 15 | 16 | @NgModule({ 17 | imports: [ 18 | BrowserModule, 19 | NxModule.forRoot(), 20 | AppRoutingModule, 21 | StoreModule.forRoot({ app: appReducer }, { initialState: { app: appInitialState } }), 22 | EffectsModule.forRoot([AppEffects]), 23 | !environment.production ? StoreDevtoolsModule.instrument() : [], 24 | StoreRouterConnectingModule 25 | ], 26 | declarations: [AppComponent], 27 | bootstrap: [AppComponent], 28 | providers: [AppEffects] 29 | }) 30 | export class AppModule {} 31 | -------------------------------------------------------------------------------- /apps/app1/src/app/core/core-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { RouterModule, Routes } from '@angular/router'; 3 | 4 | import { Feature1Component } from '../feature1/feature1.component'; 5 | import { Feature1Module } from '../feature1/feature1.module'; 6 | import { Feature2Component } from '../feature2/feature2.component'; 7 | import { Feature2Module } from '../feature2/feature2.module'; 8 | import * as fromServices from '../services'; 9 | import { CoreComponent } from './core.component'; 10 | 11 | const routes: Routes = [ 12 | // { path: 'f3', component: Feature3Component }, // having this here will make /f3 work 13 | { 14 | path: '', 15 | component: CoreComponent, 16 | resolve: { 17 | userSession: fromServices.SessionResolver 18 | }, 19 | children: [ 20 | { path: '', redirectTo: 'f1', pathMatch: 'full' }, 21 | { path: 'f1', component: Feature1Component }, 22 | { path: 'f2', component: Feature2Component }, 23 | { path: 'not-found', loadChildren: '@nx-demo-jest/not-found/src/not-found.module#NotFoundModule' }, 24 | { 25 | path: '**', 26 | redirectTo: 'not-found', 27 | pathMatch: 'full' 28 | } 29 | ] 30 | } 31 | ]; 32 | 33 | @NgModule({ 34 | imports: [ 35 | RouterModule.forChild(routes), 36 | Feature1Module, 37 | Feature2Module, 38 | ], 39 | exports: [RouterModule] 40 | }) 41 | export class CoreRoutingModule {} 42 | -------------------------------------------------------------------------------- /apps/app1/src/app/core/core.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dereklin/nx-demo-jest/68c05805cc505596680337c4afce8b7c588a9f49/apps/app1/src/app/core/core.component.css -------------------------------------------------------------------------------- /apps/app1/src/app/core/core.component.html: -------------------------------------------------------------------------------- 1 |
2 |

3 | Nrwl Nx Demo 4 | 5 |

6 |
7 | 8 | 9 | -------------------------------------------------------------------------------- /apps/app1/src/app/core/core.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { NO_ERRORS_SCHEMA } from '@angular/core'; 2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 3 | import { RouterModule } from '@angular/router'; 4 | import { RouterTestingModule } from '@angular/router/testing'; 5 | import { HttpServiceModule } from '@nx-demo-jest/http-service'; 6 | 7 | import { CoreRoutingModule } from './core-routing.module'; 8 | import { CoreComponent } from './core.component'; 9 | 10 | describe('CoreComponent', () => { 11 | let component: CoreComponent; 12 | let fixture: ComponentFixture; 13 | 14 | beforeEach( 15 | async(() => { 16 | TestBed.configureTestingModule({ 17 | declarations: [CoreComponent], 18 | imports: [ 19 | RouterModule, 20 | CoreRoutingModule, 21 | RouterTestingModule, 22 | HttpServiceModule.register({httpServiceSettings: {}}) 23 | ], 24 | schemas: [NO_ERRORS_SCHEMA] 25 | }).compileComponents(); 26 | }) 27 | ); 28 | 29 | beforeEach(() => { 30 | fixture = TestBed.createComponent(CoreComponent); 31 | component = fixture.componentInstance; 32 | fixture.detectChanges(); 33 | }); 34 | 35 | it('should create', () => { 36 | expect(component).toBeTruthy(); 37 | }); 38 | }); 39 | -------------------------------------------------------------------------------- /apps/app1/src/app/core/core.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { Tab } from '@nx-demo-jest/tab-nav'; 3 | 4 | @Component({ 5 | selector: 'app-core', 6 | templateUrl: './core.component.html', 7 | styleUrls: ['./core.component.css'] 8 | }) 9 | export class CoreComponent implements OnInit { 10 | public tabs: Tab[]; 11 | 12 | constructor() { 13 | this.tabs = [ 14 | { value: 'f1', display: 'Feature 1' }, 15 | { value: 'f2', display: 'Feature 2' }, 16 | { value: 'f3', display: 'Feature 3' } 17 | ]; 18 | } 19 | 20 | ngOnInit() {} 21 | } 22 | -------------------------------------------------------------------------------- /apps/app1/src/app/core/core.module.ts: -------------------------------------------------------------------------------- 1 | import { CommonModule } from '@angular/common'; 2 | import { NgModule } from '@angular/core'; 3 | import { HttpServiceModule } from '@nx-demo-jest/http-service'; 4 | import { TabNavModule } from '@nx-demo-jest/tab-nav'; 5 | 6 | import { environment } from '../../environments/environment'; 7 | import * as fromServices from '../services'; 8 | import { CoreRoutingModule } from './core-routing.module'; 9 | import { CoreComponent } from './core.component'; 10 | 11 | @NgModule({ 12 | imports: [ 13 | CommonModule, 14 | CoreRoutingModule, 15 | TabNavModule, 16 | HttpServiceModule.register({httpServiceSettings: environment.httpServiceSettings}) 17 | ], 18 | declarations: [CoreComponent], 19 | providers: [...fromServices.services] 20 | }) 21 | export class CoreModule {} 22 | -------------------------------------------------------------------------------- /apps/app1/src/app/feature1/feature1.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dereklin/nx-demo-jest/68c05805cc505596680337c4afce8b7c588a9f49/apps/app1/src/app/feature1/feature1.component.css -------------------------------------------------------------------------------- /apps/app1/src/app/feature1/feature1.component.html: -------------------------------------------------------------------------------- 1 |

2 | feature1 works! 3 |

4 | -------------------------------------------------------------------------------- /apps/app1/src/app/feature1/feature1.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { Feature1Component } from './feature1.component'; 4 | 5 | describe('Feature1Component', () => { 6 | let component: Feature1Component; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach( 10 | async(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [Feature1Component] 13 | }).compileComponents(); 14 | }) 15 | ); 16 | 17 | beforeEach(() => { 18 | fixture = TestBed.createComponent(Feature1Component); 19 | component = fixture.componentInstance; 20 | fixture.detectChanges(); 21 | }); 22 | 23 | it('should create', () => { 24 | expect(component).toBeTruthy(); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /apps/app1/src/app/feature1/feature1.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-feature1', 5 | templateUrl: './feature1.component.html', 6 | styleUrls: ['./feature1.component.css'] 7 | }) 8 | export class Feature1Component implements OnInit { 9 | constructor() {} 10 | 11 | ngOnInit() {} 12 | } 13 | -------------------------------------------------------------------------------- /apps/app1/src/app/feature1/feature1.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { Feature1Component } from './feature1.component'; 4 | 5 | @NgModule({ 6 | imports: [CommonModule], 7 | declarations: [Feature1Component] 8 | }) 9 | export class Feature1Module {} 10 | -------------------------------------------------------------------------------- /apps/app1/src/app/feature2/feature2.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dereklin/nx-demo-jest/68c05805cc505596680337c4afce8b7c588a9f49/apps/app1/src/app/feature2/feature2.component.css -------------------------------------------------------------------------------- /apps/app1/src/app/feature2/feature2.component.html: -------------------------------------------------------------------------------- 1 |

2 | feature2 works! 3 |

4 | -------------------------------------------------------------------------------- /apps/app1/src/app/feature2/feature2.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { Feature2Component } from './feature2.component'; 4 | 5 | describe('Feature2Component', () => { 6 | let component: Feature2Component; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach( 10 | async(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [Feature2Component] 13 | }).compileComponents(); 14 | }) 15 | ); 16 | 17 | beforeEach(() => { 18 | fixture = TestBed.createComponent(Feature2Component); 19 | component = fixture.componentInstance; 20 | fixture.detectChanges(); 21 | }); 22 | 23 | it('should create', () => { 24 | expect(component).toBeTruthy(); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /apps/app1/src/app/feature2/feature2.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-feature2', 5 | templateUrl: './feature2.component.html', 6 | styleUrls: ['./feature2.component.css'] 7 | }) 8 | export class Feature2Component implements OnInit { 9 | constructor() {} 10 | 11 | ngOnInit() {} 12 | } 13 | -------------------------------------------------------------------------------- /apps/app1/src/app/feature2/feature2.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { Feature2Component } from './feature2.component'; 4 | 5 | @NgModule({ 6 | imports: [CommonModule], 7 | declarations: [Feature2Component] 8 | }) 9 | export class Feature2Module {} 10 | -------------------------------------------------------------------------------- /apps/app1/src/app/feature3/feature3.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dereklin/nx-demo-jest/68c05805cc505596680337c4afce8b7c588a9f49/apps/app1/src/app/feature3/feature3.component.css -------------------------------------------------------------------------------- /apps/app1/src/app/feature3/feature3.component.html: -------------------------------------------------------------------------------- 1 |

2 | feature3 works! 3 |

4 | -------------------------------------------------------------------------------- /apps/app1/src/app/feature3/feature3.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { Feature3Component } from './feature3.component'; 4 | 5 | describe('Feature3Component', () => { 6 | let component: Feature3Component; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach( 10 | async(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [Feature3Component] 13 | }).compileComponents(); 14 | }) 15 | ); 16 | 17 | beforeEach(() => { 18 | fixture = TestBed.createComponent(Feature3Component); 19 | component = fixture.componentInstance; 20 | fixture.detectChanges(); 21 | }); 22 | 23 | it('should create', () => { 24 | expect(component).toBeTruthy(); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /apps/app1/src/app/feature3/feature3.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-feature3', 5 | templateUrl: './feature3.component.html', 6 | styleUrls: ['./feature3.component.css'] 7 | }) 8 | export class Feature3Component implements OnInit { 9 | constructor() {} 10 | 11 | ngOnInit() {} 12 | } 13 | -------------------------------------------------------------------------------- /apps/app1/src/app/feature3/feature3.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { Feature3Component } from './feature3.component'; 4 | 5 | @NgModule({ 6 | imports: [CommonModule], 7 | declarations: [Feature3Component], 8 | exports: [] 9 | }) 10 | export class Feature3Module {} 11 | -------------------------------------------------------------------------------- /apps/app1/src/app/services/index.ts: -------------------------------------------------------------------------------- 1 | import { SessionResolver } from '@nx-demo-jest/session-resolver'; 2 | 3 | export * from '@nx-demo-jest/session-resolver'; 4 | 5 | export const services: any[] = [SessionResolver]; 6 | -------------------------------------------------------------------------------- /apps/app1/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dereklin/nx-demo-jest/68c05805cc505596680337c4afce8b7c588a9f49/apps/app1/src/assets/.gitkeep -------------------------------------------------------------------------------- /apps/app1/src/assets/nx-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dereklin/nx-demo-jest/68c05805cc505596680337c4afce8b7c588a9f49/apps/app1/src/assets/nx-logo.png -------------------------------------------------------------------------------- /apps/app1/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true, 3 | httpServiceSettings: { 4 | endpoint: '/myprodendpoint', 5 | method: 'POST' 6 | } 7 | }; 8 | -------------------------------------------------------------------------------- /apps/app1/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // The file contents for the current environment will overwrite these during build. 2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do 3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead. 4 | // The list of which env maps to which file can be found in `.angular-cli.json`. 5 | 6 | export const environment = { 7 | production: false, 8 | httpServiceSettings: { 9 | endpoint: '/mydevendpoint', 10 | method: 'POST' 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /apps/app1/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dereklin/nx-demo-jest/68c05805cc505596680337c4afce8b7c588a9f49/apps/app1/src/favicon.ico -------------------------------------------------------------------------------- /apps/app1/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | App1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /apps/app1/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic() 12 | .bootstrapModule(AppModule) 13 | .catch(err => console.log(err)); 14 | -------------------------------------------------------------------------------- /apps/app1/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/ 22 | // import 'core-js/es6/symbol'; 23 | // import 'core-js/es6/object'; 24 | // import 'core-js/es6/function'; 25 | // import 'core-js/es6/parse-int'; 26 | // import 'core-js/es6/parse-float'; 27 | // import 'core-js/es6/number'; 28 | // import 'core-js/es6/math'; 29 | // import 'core-js/es6/string'; 30 | // import 'core-js/es6/date'; 31 | // import 'core-js/es6/array'; 32 | // import 'core-js/es6/regexp'; 33 | // import 'core-js/es6/map'; 34 | // import 'core-js/es6/weak-map'; 35 | // import 'core-js/es6/set'; 36 | 37 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 38 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 39 | 40 | /** IE10 and IE11 requires the following for the Reflect API. */ 41 | // import 'core-js/es6/reflect'; 42 | 43 | /** Evergreen browsers require these. **/ 44 | // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove. 45 | import 'core-js/es7/reflect'; 46 | 47 | /** 48 | * Required to support Web Animations `@angular/platform-browser/animations`. 49 | * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation 50 | **/ 51 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 52 | 53 | /*************************************************************************************************** 54 | * Zone JS is required by Angular itself. 55 | */ 56 | import 'zone.js/dist/zone'; // Included with Angular CLI. 57 | 58 | /*************************************************************************************************** 59 | * APPLICATION IMPORTS 60 | */ 61 | 62 | /** 63 | * Date, currency, decimal and percent pipes. 64 | * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10 65 | */ 66 | // import 'intl'; // Run `npm install --save intl`. 67 | /** 68 | * Need to import at least one locale-data with intl. 69 | */ 70 | // import 'intl/locale-data/jsonp/en'; 71 | -------------------------------------------------------------------------------- /apps/app1/src/styles.scss: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /apps/app1/src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../../dist/out-tsc/apps/app1", 5 | "module": "es2015" 6 | }, 7 | "include": [ 8 | "**/*.ts" 9 | /* add all lazy-loaded libraries here: "../../../libs/my-lib/index.ts" */ 10 | 11 | , "../../../libs/not-found/index.ts" 12 | ], 13 | "exclude": [ 14 | "**/*.spec.ts" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /apps/app2/e2e/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | 3 | describe('app2 App', () => { 4 | let page: AppPage; 5 | 6 | beforeEach(() => { 7 | page = new AppPage(); 8 | }); 9 | 10 | it('should display welcome message', () => { 11 | page.navigateTo(); 12 | expect(page.text()).toContain('Welcome'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /apps/app2/e2e/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | text() { 9 | return browser.findElement(by.css('body')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /apps/app2/e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../../dist/out-tsc/e2e/app2", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | }, 13 | "include": [ 14 | "../**/*.ts" 15 | /* add all lazy-loaded libraries here: "../../../libs/my-lib/index.ts" */ 16 | ], 17 | "exclude": [ 18 | "**/*.spec.ts" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /apps/app2/src/app/app.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dereklin/nx-demo-jest/68c05805cc505596680337c4afce8b7c588a9f49/apps/app2/src/app/app.component.css -------------------------------------------------------------------------------- /apps/app2/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |

4 | Welcome to an Angular CLI app built with Nrwl Nx! 5 |

6 | 7 |
8 | 9 |

Nx

10 | 11 | An open source toolkit for enterprise Angular applications. 12 | 13 | Nx is designed to help you create and build enterprise grade Angular applications. It provides an opinionated approach to application project structure and patterns. 14 | 15 |

Quick Start & Documentation

16 | 17 | Watch a 5-minute video on how to get started with Nx. 18 | -------------------------------------------------------------------------------- /apps/app2/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { AppComponent } from './app.component'; 4 | import { RouterTestingModule } from '@angular/router/testing'; 5 | 6 | describe('AppComponent', () => { 7 | let component: AppComponent; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach( 11 | async(() => { 12 | TestBed.configureTestingModule({ 13 | imports: [RouterTestingModule], 14 | declarations: [AppComponent] 15 | }).compileComponents(); 16 | }) 17 | ); 18 | 19 | beforeEach(() => { 20 | fixture = TestBed.createComponent(AppComponent); 21 | component = fixture.componentInstance; 22 | fixture.detectChanges(); 23 | }); 24 | 25 | it('should create', () => { 26 | expect(component).toBeTruthy(); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /apps/app2/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.css'] 7 | }) 8 | export class AppComponent implements OnInit { 9 | constructor() {} 10 | 11 | ngOnInit() {} 12 | } 13 | -------------------------------------------------------------------------------- /apps/app2/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { AppComponent } from './app.component'; 3 | import { BrowserModule } from '@angular/platform-browser'; 4 | import { NxModule } from '@nrwl/nx'; 5 | import { RouterModule } from '@angular/router'; 6 | 7 | @NgModule({ 8 | imports: [BrowserModule, NxModule.forRoot(), RouterModule.forRoot([], { initialNavigation: 'enabled' })], 9 | declarations: [AppComponent], 10 | bootstrap: [AppComponent] 11 | }) 12 | export class AppModule {} 13 | -------------------------------------------------------------------------------- /apps/app2/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dereklin/nx-demo-jest/68c05805cc505596680337c4afce8b7c588a9f49/apps/app2/src/assets/.gitkeep -------------------------------------------------------------------------------- /apps/app2/src/assets/nx-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dereklin/nx-demo-jest/68c05805cc505596680337c4afce8b7c588a9f49/apps/app2/src/assets/nx-logo.png -------------------------------------------------------------------------------- /apps/app2/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /apps/app2/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // The file contents for the current environment will overwrite these during build. 2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do 3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead. 4 | // The list of which env maps to which file can be found in `.angular-cli.json`. 5 | 6 | export const environment = { 7 | production: false 8 | }; 9 | -------------------------------------------------------------------------------- /apps/app2/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dereklin/nx-demo-jest/68c05805cc505596680337c4afce8b7c588a9f49/apps/app2/src/favicon.ico -------------------------------------------------------------------------------- /apps/app2/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | App2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /apps/app2/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic() 12 | .bootstrapModule(AppModule) 13 | .catch(err => console.log(err)); 14 | -------------------------------------------------------------------------------- /apps/app2/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/ 22 | // import 'core-js/es6/symbol'; 23 | // import 'core-js/es6/object'; 24 | // import 'core-js/es6/function'; 25 | // import 'core-js/es6/parse-int'; 26 | // import 'core-js/es6/parse-float'; 27 | // import 'core-js/es6/number'; 28 | // import 'core-js/es6/math'; 29 | // import 'core-js/es6/string'; 30 | // import 'core-js/es6/date'; 31 | // import 'core-js/es6/array'; 32 | // import 'core-js/es6/regexp'; 33 | // import 'core-js/es6/map'; 34 | // import 'core-js/es6/weak-map'; 35 | // import 'core-js/es6/set'; 36 | 37 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 38 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 39 | 40 | /** IE10 and IE11 requires the following for the Reflect API. */ 41 | // import 'core-js/es6/reflect'; 42 | 43 | /** Evergreen browsers require these. **/ 44 | // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove. 45 | import 'core-js/es7/reflect'; 46 | 47 | /** 48 | * Required to support Web Animations `@angular/platform-browser/animations`. 49 | * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation 50 | **/ 51 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 52 | 53 | /*************************************************************************************************** 54 | * Zone JS is required by Angular itself. 55 | */ 56 | import 'zone.js/dist/zone'; // Included with Angular CLI. 57 | 58 | /*************************************************************************************************** 59 | * APPLICATION IMPORTS 60 | */ 61 | 62 | /** 63 | * Date, currency, decimal and percent pipes. 64 | * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10 65 | */ 66 | // import 'intl'; // Run `npm install --save intl`. 67 | /** 68 | * Need to import at least one locale-data with intl. 69 | */ 70 | // import 'intl/locale-data/jsonp/en'; 71 | -------------------------------------------------------------------------------- /apps/app2/src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /apps/app2/src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../../dist/out-tsc/apps/app2", 5 | "module": "es2015" 6 | }, 7 | "include": [ 8 | "**/*.ts" 9 | /* add all lazy-loaded libraries here: "../../../libs/my-lib/index.ts" */ 10 | ], 11 | "exclude": [ 12 | "**/*.spec.ts" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /jest/jestGlobalMocks.ts: -------------------------------------------------------------------------------- 1 | const mock = () => { 2 | let storage = {}; 3 | return { 4 | getItem: key => key in storage ? storage[key] : null, 5 | setItem: (key, value) => storage[key] = value || '', 6 | removeItem: key => delete storage[key], 7 | clear: () => storage = {}, 8 | getStorage: () => storage 9 | }; 10 | }; 11 | 12 | Object.defineProperty(window, 'localStorage', {value: mock()}); 13 | Object.defineProperty(global, 'localStorage', {value: mock()}); 14 | Object.defineProperty(window, 'sessionStorage', {value: mock()}); 15 | Object.defineProperty(global, 'sessionStorage', {value: mock()}); 16 | 17 | Object.defineProperty(window, 'getComputedStyle', { 18 | value: () => ['-webkit-appearance'] 19 | }); 20 | Object.defineProperty(global, 'getComputedStyle', { 21 | value: () => ['-webkit-appearance'] 22 | }); 23 | Object.defineProperty(window, 'CSS', {value: mock()}); 24 | -------------------------------------------------------------------------------- /jest/setupJest.ts: -------------------------------------------------------------------------------- 1 | import 'jest-preset-angular'; 2 | import './jestGlobalMocks'; 3 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | const { makeSureNoAppIsSelected } = require('@nrwl/schematics/src/utils/cli-config-utils'); 5 | // Nx only supports running unit tests for all apps and libs. 6 | makeSureNoAppIsSelected(); 7 | 8 | module.exports = function (config) { 9 | config.set({ 10 | basePath: '', 11 | frameworks: ['jasmine', '@angular/cli'], 12 | plugins: [ 13 | require('karma-jasmine'), 14 | require('karma-chrome-launcher'), 15 | require('karma-jasmine-html-reporter'), 16 | require('karma-coverage-istanbul-reporter'), 17 | require('@angular/cli/plugins/karma') 18 | ], 19 | client:{ 20 | clearContext: false // leave Jasmine Spec Runner output visible in browser 21 | }, 22 | coverageIstanbulReporter: { 23 | reports: [ 'html', 'lcovonly' ], 24 | fixWebpackSourcePaths: true 25 | }, 26 | angularCli: { 27 | environment: 'dev' 28 | }, 29 | reporters: ['progress', 'kjhtml'], 30 | port: 9876, 31 | colors: true, 32 | logLevel: config.LOG_INFO, 33 | autoWatch: true, 34 | browsers: ['Chrome'], 35 | singleRun: false 36 | }); 37 | }; 38 | -------------------------------------------------------------------------------- /libs/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dereklin/nx-demo-jest/68c05805cc505596680337c4afce8b7c588a9f49/libs/.gitkeep -------------------------------------------------------------------------------- /libs/http-service/index.ts: -------------------------------------------------------------------------------- 1 | export { HttpServiceModule } from './src/http-service.module'; 2 | export { HTTPSERVICE } from './src/http-service.tokens'; 3 | export { HttpService } from './src/http-service'; 4 | export { SimpleHttpService } from './src/simple-http.service'; 5 | export { HttpClientService } from './src/http-client.service'; 6 | -------------------------------------------------------------------------------- /libs/http-service/src/http-client.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { HttpClientModule } from '@angular/common/http'; 2 | import { TestBed, inject } from '@angular/core/testing'; 3 | 4 | import { HttpClientService } from './http-client.service'; 5 | 6 | describe('HttpClientService', () => { 7 | beforeEach(() => { 8 | TestBed.configureTestingModule({ 9 | providers: [HttpClientService], 10 | imports: [HttpClientModule] 11 | }); 12 | }); 13 | 14 | it( 15 | 'should be created', 16 | inject([HttpClientService], (service: HttpClientService) => { 17 | expect(service).toBeTruthy(); 18 | }) 19 | ); 20 | }); 21 | -------------------------------------------------------------------------------- /libs/http-service/src/http-client.service.ts: -------------------------------------------------------------------------------- 1 | // This code is not tested and might cause errors 2 | import { HttpClient, HttpHeaders } from '@angular/common/http'; 3 | import { Injectable } from '@angular/core'; 4 | import { Response } from '@angular/http'; 5 | import { Observable } from 'rxjs/Observable'; 6 | import { of } from 'rxjs/observable/of'; 7 | import { catchError, map } from 'rxjs/operators'; 8 | 9 | @Injectable() 10 | export class HttpClientService { 11 | private headers: HttpHeaders; 12 | 13 | constructor(private http: HttpClient) { 14 | this.headers = new HttpHeaders({ 'Content-Type': 'application/json', Accept: 'application/json' }); 15 | this.headers.append('Cache-control', 'no-cache'); 16 | this.headers.append('Cache-control', 'no-store'); 17 | this.headers.append('Expires', '0'); 18 | this.headers.append('Pragma', 'no-cache'); 19 | } 20 | 21 | public post(url, data): Observable { 22 | return this.http 23 | .post(url, data, { headers: this.headers }) 24 | .pipe(map(this.extractData), catchError(this.handleError)); 25 | } 26 | 27 | private extractData(res: Response) { 28 | return res; 29 | } 30 | 31 | private handleError(error: Response | any) { 32 | let errMsg: string; 33 | if (error instanceof Response) { 34 | try { 35 | errMsg = `${error.status} - ${error.statusText || ''}`; 36 | const body = error.json() || ''; 37 | const err = body.error || JSON.stringify(body); 38 | errMsg = `${errMsg} ${err}`; 39 | } catch (e2) { 40 | if (error['_body']) { 41 | errMsg = `${errMsg} ${error['_body']}`; 42 | } 43 | } 44 | } else { 45 | errMsg = error ? (error.message ? error.message : error.toString()) : ''; 46 | } 47 | console.error(errMsg); 48 | return of(undefined); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /libs/http-service/src/http-service.module.spec.ts: -------------------------------------------------------------------------------- 1 | import { HttpServiceModule } from './http-service.module'; 2 | 3 | describe('HttpServiceModule', () => { 4 | it('should work', () => { 5 | expect(new HttpServiceModule()).toBeDefined(); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /libs/http-service/src/http-service.module.ts: -------------------------------------------------------------------------------- 1 | import { HttpClientModule } from '@angular/common/http'; 2 | import { HttpClientService } from './http-client.service'; 3 | import { SimpleHttpService } from './simple-http.service'; 4 | import { HTTPSERVICE, HTTPSERVICESETTINGS } from './http-service.tokens'; 5 | import { ModuleWithProviders, NgModule } from '@angular/core'; 6 | import { CommonModule } from '@angular/common'; 7 | 8 | @NgModule({ 9 | imports: [CommonModule, HttpClientModule] 10 | }) 11 | export class HttpServiceModule { 12 | public static register({httpServiceSettings}): ModuleWithProviders { 13 | return { 14 | ngModule: HttpServiceModule, 15 | providers: [ 16 | { provide: HTTPSERVICESETTINGS, useValue: httpServiceSettings }, 17 | { provide: HTTPSERVICE, useClass: SimpleHttpService }, 18 | HttpClientService 19 | ] 20 | }; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /libs/http-service/src/http-service.tokens.ts: -------------------------------------------------------------------------------- 1 | import { InjectionToken } from '@angular/core'; 2 | 3 | export const HTTPSERVICE = new InjectionToken('http-service'); 4 | export const HTTPSERVICESETTINGS = new InjectionToken('http-service-settings'); 5 | -------------------------------------------------------------------------------- /libs/http-service/src/http-service.ts: -------------------------------------------------------------------------------- 1 | import { Observable } from 'rxjs/Observable'; 2 | 3 | export interface HttpService { 4 | post(service: string, method: string, request: any): Observable; 5 | } 6 | -------------------------------------------------------------------------------- /libs/http-service/src/simple-http.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { HTTPSERVICESETTINGS } from './http-service.tokens'; 2 | import { HttpClientService } from './http-client.service'; 3 | import { HttpClientModule } from '@angular/common/http'; 4 | import { TestBed, inject } from '@angular/core/testing'; 5 | 6 | import { SimpleHttpService } from './simple-http.service'; 7 | 8 | describe('SimpleHttpServiceService', () => { 9 | beforeEach(() => { 10 | TestBed.configureTestingModule({ 11 | providers: [ 12 | SimpleHttpService, 13 | HttpClientService, 14 | { provide: HTTPSERVICESETTINGS, useValue: {} } 15 | ], 16 | imports: [HttpClientModule] 17 | }); 18 | }); 19 | 20 | it( 21 | 'should be created', 22 | inject([SimpleHttpService], (service: SimpleHttpService) => { 23 | expect(service).toBeTruthy(); 24 | }) 25 | ); 26 | }); 27 | -------------------------------------------------------------------------------- /libs/http-service/src/simple-http.service.ts: -------------------------------------------------------------------------------- 1 | import { HTTPSERVICESETTINGS } from './http-service.tokens'; 2 | import { HttpService } from './http-service'; 3 | import { Inject, Injectable } from '@angular/core'; 4 | import { Observable } from 'rxjs/Observable'; 5 | import { empty } from 'rxjs/observable/empty'; 6 | 7 | import { HttpClientService } from './http-client.service'; 8 | import { map, catchError } from 'rxjs/operators'; 9 | import { of } from 'rxjs/observable/of'; 10 | 11 | @Injectable() 12 | export class SimpleHttpService implements HttpService { 13 | constructor( 14 | private httpClientService: HttpClientService, 15 | @Inject(HTTPSERVICESETTINGS) private httpServiceSettings: any 16 | ) {} 17 | 18 | /** 19 | * Construct a complete url and post request 20 | * @param service 21 | * @param method 22 | * @param request 23 | * @returns {Observable} 24 | */ 25 | public post(service: string, method: string, request: any): Observable { 26 | console.log('httpServiceSettings', this.httpServiceSettings); 27 | return of({ name: 'test' }); 28 | } 29 | 30 | private paramaterizeJson(data) { 31 | return Object.keys(data) 32 | .map(k => { 33 | let value = data[k]; 34 | if (typeof value === 'object') { 35 | value = JSON.stringify(value); 36 | } 37 | return encodeURIComponent(k) + '=' + encodeURIComponent(value); 38 | }) 39 | .join('&'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /libs/not-found/index.ts: -------------------------------------------------------------------------------- 1 | export { NotFoundModule } from './src/not-found.module'; 2 | export { NotFoundComponent } from './src/not-found/not-found.component'; 3 | -------------------------------------------------------------------------------- /libs/not-found/src/not-found.module.spec.ts: -------------------------------------------------------------------------------- 1 | import { NotFoundModule } from './not-found.module'; 2 | 3 | describe('NotFoundModule', () => { 4 | it('should work', () => { 5 | expect(new NotFoundModule()).toBeDefined(); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /libs/not-found/src/not-found.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { RouterModule } from '@angular/router'; 4 | import { NotFoundComponent } from './not-found/not-found.component'; 5 | 6 | @NgModule({ 7 | imports: [CommonModule, RouterModule.forChild([{ path: '', component: NotFoundComponent }])], 8 | declarations: [NotFoundComponent] 9 | }) 10 | export class NotFoundModule {} 11 | -------------------------------------------------------------------------------- /libs/not-found/src/not-found/not-found.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dereklin/nx-demo-jest/68c05805cc505596680337c4afce8b7c588a9f49/libs/not-found/src/not-found/not-found.component.css -------------------------------------------------------------------------------- /libs/not-found/src/not-found/not-found.component.html: -------------------------------------------------------------------------------- 1 |

2 | Page Not Found 3 |

4 | -------------------------------------------------------------------------------- /libs/not-found/src/not-found/not-found.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { NotFoundComponent } from './not-found.component'; 4 | 5 | describe('NotFoundComponent', () => { 6 | let component: NotFoundComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach( 10 | async(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [NotFoundComponent] 13 | }).compileComponents(); 14 | }) 15 | ); 16 | 17 | beforeEach(() => { 18 | fixture = TestBed.createComponent(NotFoundComponent); 19 | component = fixture.componentInstance; 20 | fixture.detectChanges(); 21 | }); 22 | 23 | it('should create', () => { 24 | expect(component).toBeTruthy(); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /libs/not-found/src/not-found/not-found.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-not-found', 5 | templateUrl: './not-found.component.html', 6 | styleUrls: ['./not-found.component.css'] 7 | }) 8 | export class NotFoundComponent implements OnInit { 9 | constructor() {} 10 | 11 | ngOnInit() {} 12 | } 13 | -------------------------------------------------------------------------------- /libs/session-resolver/index.ts: -------------------------------------------------------------------------------- 1 | export { SessionResolver } from './src/session-resolver'; 2 | -------------------------------------------------------------------------------- /libs/session-resolver/src/session-resolver.spec.ts: -------------------------------------------------------------------------------- 1 | import { SessionResolver } from './session-resolver'; 2 | 3 | describe('SessionResolver', () => { 4 | it('should work', () => { 5 | expect(new SessionResolver()).toBeDefined(); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /libs/session-resolver/src/session-resolver.ts: -------------------------------------------------------------------------------- 1 | import { Inject, Injectable } from '@angular/core'; 2 | import { ActivatedRouteSnapshot, Resolve } from '@angular/router'; 3 | import { Observable } from 'rxjs/Observable'; 4 | import { delay } from 'rxjs/operators'; 5 | import { HTTPSERVICE, HttpService } from '@nx-demo-jest/http-service'; 6 | 7 | @Injectable() 8 | export class SessionResolver implements Resolve { 9 | 10 | constructor( @Inject(HTTPSERVICE) private simpleHttpService: HttpService) { } 11 | 12 | public resolve() { 13 | return this.simpleHttpService.post('sessionService', 'getUserSession', {}); 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /libs/stringutils/index.ts: -------------------------------------------------------------------------------- 1 | export { Stringutils } from './src/stringutils'; 2 | -------------------------------------------------------------------------------- /libs/stringutils/src/stringutils.spec.ts: -------------------------------------------------------------------------------- 1 | import { Stringutils } from './stringutils'; 2 | 3 | describe('Stringutils', () => { 4 | it('should work', () => { 5 | expect(new Stringutils()).toBeDefined(); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /libs/stringutils/src/stringutils.ts: -------------------------------------------------------------------------------- 1 | export class Stringutils {} 2 | -------------------------------------------------------------------------------- /libs/tab-nav/index.ts: -------------------------------------------------------------------------------- 1 | export { TabNavModule } from './src/tab-nav.module'; 2 | export { Tab } from './src/models/tab.model'; 3 | -------------------------------------------------------------------------------- /libs/tab-nav/src/models/tab.model.ts: -------------------------------------------------------------------------------- 1 | export interface Tab { 2 | value: string; 3 | display: string; 4 | } 5 | -------------------------------------------------------------------------------- /libs/tab-nav/src/tab-nav.module.spec.ts: -------------------------------------------------------------------------------- 1 | import { TabNavModule } from './tab-nav.module'; 2 | 3 | describe('TabNavModule', () => { 4 | it('should work', () => { 5 | expect(new TabNavModule()).toBeDefined(); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /libs/tab-nav/src/tab-nav.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { TabNavComponent } from './tab-nav/tab-nav.component'; 4 | import { RouterModule } from '@angular/router'; 5 | 6 | @NgModule({ 7 | imports: [CommonModule, RouterModule], 8 | declarations: [TabNavComponent], 9 | exports: [TabNavComponent] 10 | }) 11 | export class TabNavModule {} 12 | -------------------------------------------------------------------------------- /libs/tab-nav/src/tab-nav/tab-nav.component.html: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /libs/tab-nav/src/tab-nav/tab-nav.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dereklin/nx-demo-jest/68c05805cc505596680337c4afce8b7c588a9f49/libs/tab-nav/src/tab-nav/tab-nav.component.scss -------------------------------------------------------------------------------- /libs/tab-nav/src/tab-nav/tab-nav.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { NO_ERRORS_SCHEMA } from '@angular/core'; 2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 3 | 4 | import { TabNavComponent } from './tab-nav.component'; 5 | 6 | describe('TabNavComponent', () => { 7 | let component: TabNavComponent; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach( 11 | async(() => { 12 | TestBed.configureTestingModule({ 13 | declarations: [TabNavComponent], 14 | schemas: [NO_ERRORS_SCHEMA] 15 | }).compileComponents(); 16 | }) 17 | ); 18 | 19 | beforeEach(() => { 20 | fixture = TestBed.createComponent(TabNavComponent); 21 | component = fixture.componentInstance; 22 | fixture.detectChanges(); 23 | }); 24 | 25 | it('should create', () => { 26 | expect(component).toBeTruthy(); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /libs/tab-nav/src/tab-nav/tab-nav.component.ts: -------------------------------------------------------------------------------- 1 | import { Tab } from '../models/tab.model'; 2 | import { Component, Input, OnInit } from '@angular/core'; 3 | 4 | @Component({ 5 | selector: 'my-tab-nav', 6 | templateUrl: './tab-nav.component.html', 7 | styleUrls: ['./tab-nav.component.scss'] 8 | }) 9 | export class TabNavComponent implements OnInit { 10 | @Input() public tabs: Tab[]; 11 | 12 | constructor() {} 13 | 14 | ngOnInit() {} 15 | } 16 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nx-demo-jest", 3 | "version": "0.0.0", 4 | "license": "MIT", 5 | "scripts": { 6 | "ng": "ng", 7 | "start": "ng serve", 8 | "start:app1": "npm start -- --app=app1 --port 4201 --open", 9 | "build": "ng build", 10 | "test": "ng test", 11 | "lint": "./node_modules/.bin/nx lint && ng lint", 12 | "e2e": "ng e2e", 13 | "format": "./node_modules/.bin/nx format:write", 14 | "jest": "jest", 15 | "affected:apps": "./node_modules/.bin/nx affected:apps", 16 | "affected:build": "./node_modules/.bin/nx affected:build", 17 | "affected:e2e": "./node_modules/.bin/nx affected:e2e", 18 | "format:write": "./node_modules/.bin/nx format:write", 19 | "format:check": "./node_modules/.bin/nx format:check", 20 | "postinstall": "./node_modules/.bin/nx postinstall", 21 | "update": "./node_modules/.bin/nx update", 22 | "update:check": "./node_modules/.bin/nx update:check", 23 | "update:skip": "./node_modules/.bin/nx update:skip", 24 | "dep-graph": "./node_modules/.bin/nx dep-graph", 25 | "affected:dep-graph": "./node_modules/.bin/nx affected:dep-graph", 26 | "workspace-schematic": "./node_modules/.bin/nx workspace-schematic", 27 | "help": "./node_modules/.bin/nx help" 28 | }, 29 | "private": true, 30 | "dependencies": { 31 | "@angular/animations": "5.2.7", 32 | "@angular/common": "5.2.7", 33 | "@angular/compiler": "5.2.7", 34 | "@angular/core": "5.2.7", 35 | "@angular/forms": "5.2.7", 36 | "@angular/http": "5.2.7", 37 | "@angular/platform-browser": "5.2.7", 38 | "@angular/platform-browser-dynamic": "5.2.7", 39 | "@angular/router": "5.2.7", 40 | "@ngrx/effects": "5.1.0", 41 | "@ngrx/router-store": "5.0.1", 42 | "@ngrx/store": "5.1.0", 43 | "@ngrx/store-devtools": "5.1.0", 44 | "@nrwl/nx": "1.0.3", 45 | "bootstrap": "4.0.0-beta", 46 | "core-js": "^2.4.1", 47 | "jquery": "3.2.1", 48 | "rxjs": "^5.5.6", 49 | "zone.js": "^0.8.19" 50 | }, 51 | "devDependencies": { 52 | "@angular/cli": "1.7.1", 53 | "@angular/compiler-cli": "5.2.7", 54 | "@angular/language-service": "5.2.7", 55 | "@nrwl/schematics": "1.0.3", 56 | "@types/jest": "^22.2.3", 57 | "@types/jquery": "3.2.17", 58 | "@types/node": "8.5.2", 59 | "codelyzer": "4.0.2", 60 | "jasmine-core": "^3.1.0", 61 | "jasmine-spec-reporter": "~4.2.1", 62 | "jest": "^22.4.4", 63 | "jest-html-reporter": "^2.3.0", 64 | "jest-preset-angular": "^5.2.2", 65 | "karma": "~2.0.0", 66 | "karma-chrome-launcher": "~2.2.0", 67 | "karma-coverage-istanbul-reporter": "^2.0.0", 68 | "karma-jasmine": "^1.1.2", 69 | "karma-jasmine-html-reporter": "^1.1.0", 70 | "prettier": "1.10.2", 71 | "protractor": "5.2.2", 72 | "rxjs-marbles": "2.3.0", 73 | "ts-node": "~4.1.0", 74 | "tslint": "~5.9.1", 75 | "typescript": "2.6.2" 76 | }, 77 | "jest": { 78 | "preset": "jest-preset-angular", 79 | "setupTestFrameworkScriptFile": "/jest/setupJest.ts", 80 | "globals": { 81 | "ts-jest": { 82 | "tsConfigFile": "tsconfig.spec.json" 83 | }, 84 | "__TRANSFORM_HTML__": true, 85 | "testResultsProcessor": "./node_modules/jest-html-reporter" 86 | }, 87 | "collectCoverageFrom": [ 88 | "{apps|libs}/**/src/**/*.ts", 89 | "!jest/*.ts", 90 | "!{apps|libs}/**/src/**/*module.ts", 91 | "!apps/**/src/environments/*.ts", 92 | "!apps/**/src/main.ts", 93 | "!apps/**/src/polyfills.ts" 94 | ], 95 | "coverageThreshold": { 96 | "global": { 97 | "branches": 60, 98 | "functions": 60, 99 | "lines": 60, 100 | "statements": -20 101 | } 102 | }, 103 | "moduleNameMapper": { 104 | "@nx-demo-jest/(.*)": "/libs/$1" 105 | } 106 | }, 107 | "jest-html-reporter": { 108 | "pageTitle": "Your test suite", 109 | "outputPath": "coverage/index.html", 110 | "includeFailureMsg": false 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | const { getAppDirectoryUsingCliConfig } = require('@nrwl/schematics/src/utils/cli-config-utils'); 6 | const appDir = getAppDirectoryUsingCliConfig(); 7 | 8 | exports.config = { 9 | allScriptsTimeout: 11000, 10 | specs: [ 11 | appDir + '/e2e/**/*.e2e-spec.ts' 12 | ], 13 | capabilities: { 14 | 'browserName': 'chrome' 15 | }, 16 | directConnect: true, 17 | baseUrl: 'http://localhost:4200/', 18 | framework: 'jasmine', 19 | jasmineNodeOpts: { 20 | showColors: true, 21 | defaultTimeoutInterval: 30000, 22 | print: function() {} 23 | }, 24 | onPrepare() { 25 | require('ts-node').register({ 26 | project: appDir + '/e2e/tsconfig.e2e.json' 27 | }); 28 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | 2 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 3 | require('zone.js/dist/zone-testing'); 4 | const getTestBed = require('@angular/core/testing').getTestBed; 5 | const BrowserDynamicTestingModule = require('@angular/platform-browser-dynamic/testing').BrowserDynamicTestingModule; 6 | const platformBrowserDynamicTesting = require('@angular/platform-browser-dynamic/testing').platformBrowserDynamicTesting; 7 | 8 | // Prevent Karma from running prematurely. 9 | __karma__.loaded = function () {}; 10 | 11 | // First, initialize the Angular testing environment. 12 | getTestBed().initTestEnvironment( 13 | BrowserDynamicTestingModule, 14 | platformBrowserDynamicTesting() 15 | ); 16 | // Then we find all the tests. 17 | const contextApps = require.context('./apps', true, /\.spec\.ts$/); 18 | // And load the modules. 19 | contextApps.keys().map(contextApps); 20 | 21 | const contextLibs = require.context('./libs', true, /\.spec\.ts$/); 22 | // And load the modules. 23 | contextLibs.keys().map(contextLibs); 24 | 25 | // Finally, start Karma to run the tests. 26 | __karma__.start(); 27 | -------------------------------------------------------------------------------- /tools/schematics/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dereklin/nx-demo-jest/68c05805cc505596680337c4afce8b7c588a9f49/tools/schematics/.gitkeep -------------------------------------------------------------------------------- /tools/tsconfig.tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../dist/out-tsc/tools", 5 | "rootDir": ".", 6 | "module": "commonjs", 7 | "target": "es5", 8 | "types": [ 9 | "jasmine", 10 | "node" 11 | ] 12 | }, 13 | "include": [ 14 | "**/*.ts" 15 | ] 16 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "sourceMap": true, 5 | "declaration": false, 6 | "moduleResolution": "node", 7 | "emitDecoratorMetadata": true, 8 | "experimentalDecorators": true, 9 | "target": "es5", 10 | "typeRoots": [ 11 | "node_modules/@types" 12 | ], 13 | "lib": [ 14 | "es2017", 15 | "dom" 16 | ], 17 | "baseUrl": ".", 18 | "paths": { 19 | "@nx-demo-jest/*": [ 20 | "libs/*" 21 | ] 22 | } 23 | }, 24 | "exclude": [ 25 | "node_modules", 26 | "tmp" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist/out-tsc/spec", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jest", 9 | "node" 10 | ] 11 | }, 12 | "include": [ 13 | "**/*.ts" 14 | ], 15 | "exclude": [ 16 | "**/e2e/*.ts", 17 | "**/*.e2e-spec.ts", 18 | "**/*.po.ts", 19 | "node_modules", 20 | "tmp", 21 | "jest/*.ts" 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": [ 3 | "node_modules/codelyzer", 4 | "node_modules/@nrwl/schematics/src/tslint" 5 | ], 6 | "rules": { 7 | "arrow-return-shorthand": true, 8 | "callable-types": true, 9 | "class-name": true, 10 | "comment-format": [ 11 | true, 12 | "check-space" 13 | ], 14 | "curly": true, 15 | "eofline": true, 16 | "forin": true, 17 | "import-blacklist": [ 18 | true, 19 | "rxjs" 20 | ], 21 | "import-spacing": true, 22 | "indent": [ 23 | true, 24 | "spaces" 25 | ], 26 | "interface-over-type-literal": true, 27 | "label-position": true, 28 | "max-line-length": [ 29 | true, 30 | 140 31 | ], 32 | "member-access": false, 33 | "member-ordering": [ 34 | true, 35 | { 36 | "order": [ 37 | "static-field", 38 | "instance-field", 39 | "static-method", 40 | "instance-method" 41 | ] 42 | } 43 | ], 44 | "no-arg": true, 45 | "no-bitwise": true, 46 | "no-console": [ 47 | true, 48 | "debug", 49 | "info", 50 | "time", 51 | "timeEnd", 52 | "trace" 53 | ], 54 | "no-construct": true, 55 | "no-debugger": true, 56 | "no-duplicate-super": true, 57 | "no-empty": false, 58 | "no-empty-interface": true, 59 | "no-eval": true, 60 | "no-inferrable-types": [ 61 | true, 62 | "ignore-params" 63 | ], 64 | "no-misused-new": true, 65 | "no-non-null-assertion": true, 66 | "no-shadowed-variable": true, 67 | "no-string-literal": false, 68 | "no-string-throw": true, 69 | "no-switch-case-fall-through": true, 70 | "no-unnecessary-initializer": true, 71 | "no-unused-expression": true, 72 | "no-use-before-declare": true, 73 | "no-var-keyword": true, 74 | "object-literal-sort-keys": false, 75 | "prefer-const": true, 76 | "radix": true, 77 | "semicolon": [ 78 | true, 79 | "always" 80 | ], 81 | "triple-equals": [ 82 | true, 83 | "allow-null-check" 84 | ], 85 | "unified-signatures": true, 86 | "variable-name": false, 87 | "directive-selector": [ 88 | true, 89 | "attribute", 90 | "app", 91 | "camelCase" 92 | ], 93 | "component-selector": [ 94 | true, 95 | "element", 96 | "app", 97 | "kebab-case" 98 | ], 99 | "use-input-property-decorator": true, 100 | "use-output-property-decorator": true, 101 | "use-host-property-decorator": true, 102 | "no-input-rename": true, 103 | "no-output-rename": true, 104 | "use-life-cycle-interface": true, 105 | "use-pipe-transform-interface": true, 106 | "component-class-suffix": true, 107 | "directive-class-suffix": true, 108 | "no-access-missing-member": true, 109 | "templates-use-public": true, 110 | "invoke-injectable": true, 111 | "nx-enforce-module-boundaries": [ 112 | true, 113 | { 114 | "allow": [], 115 | "depConstraints": [ 116 | { 117 | "sourceTag": "*", 118 | "onlyDependOnLibsWithTags": [ 119 | "*" 120 | ] 121 | } 122 | ] 123 | } 124 | ], 125 | "deprecation": { 126 | "severity": "warn" 127 | } 128 | } 129 | } 130 | --------------------------------------------------------------------------------