├── .angular-cli.json
├── .editorconfig
├── .gitignore
├── .vscode
└── settings.json
├── README.md
├── db.json
├── e2e
├── app.e2e-spec.ts
├── app.po.ts
├── tsconfig.e2e.json
└── users
│ ├── users.e2e-spec.ts
│ └── users.po.ts
├── karma.conf.js
├── package-lock.json
├── package.json
├── protractor.conf.js
├── src
├── app
│ ├── app.component.css
│ ├── app.component.html
│ ├── app.component.spec.ts
│ ├── app.component.ts
│ ├── app.module.ts
│ ├── components
│ │ ├── user-edit-form
│ │ │ ├── user-edit-form.component.css
│ │ │ ├── user-edit-form.component.html
│ │ │ ├── user-edit-form.component.spec.ts
│ │ │ └── user-edit-form.component.ts
│ │ └── user-list
│ │ │ ├── user-list.component.css
│ │ │ ├── user-list.component.html
│ │ │ ├── user-list.component.spec.ts
│ │ │ └── user-list.component.ts
│ ├── containers
│ │ ├── user
│ │ │ ├── user.component.css
│ │ │ ├── user.component.html
│ │ │ ├── user.component.spec.ts
│ │ │ └── user.component.ts
│ │ └── users
│ │ │ ├── users.component.css
│ │ │ ├── users.component.html
│ │ │ ├── users.component.spec.ts
│ │ │ └── users.component.ts
│ ├── models
│ │ └── user.ts
│ └── services
│ │ ├── user.service.spec.ts
│ │ └── user.service.ts
├── assets
│ └── .gitkeep
├── environments
│ ├── environment.prod.ts
│ └── environment.ts
├── favicon.ico
├── index.html
├── main.ts
├── polyfills.ts
├── styles.css
├── test.ts
├── tsconfig.app.json
├── tsconfig.spec.json
├── typings.d.ts
└── wallabyTest.ts
├── tsconfig.json
├── tslint.json
└── wallaby.js
/.angular-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "project": {
4 | "name": "test-angular-draft"
5 | },
6 | "apps": [
7 | {
8 | "root": "src",
9 | "outDir": "dist",
10 | "assets": [
11 | "assets",
12 | "favicon.ico"
13 | ],
14 | "index": "index.html",
15 | "main": "main.ts",
16 | "polyfills": "polyfills.ts",
17 | "test": "test.ts",
18 | "tsconfig": "tsconfig.app.json",
19 | "testTsconfig": "tsconfig.spec.json",
20 | "prefix": "app",
21 | "styles": [
22 | "styles.css"
23 | ],
24 | "scripts": [],
25 | "environmentSource": "environments/environment.ts",
26 | "environments": {
27 | "dev": "environments/environment.ts",
28 | "prod": "environments/environment.prod.ts"
29 | }
30 | }
31 | ],
32 | "e2e": {
33 | "protractor": {
34 | "config": "./protractor.conf.js"
35 | }
36 | },
37 | "lint": [
38 | {
39 | "project": "src/tsconfig.app.json",
40 | "exclude": "**/node_modules/**"
41 | },
42 | {
43 | "project": "src/tsconfig.spec.json",
44 | "exclude": "**/node_modules/**"
45 | },
46 | {
47 | "project": "e2e/tsconfig.e2e.json",
48 | "exclude": "**/node_modules/**"
49 | }
50 | ],
51 | "test": {
52 | "karma": {
53 | "config": "./karma.conf.js"
54 | }
55 | },
56 | "defaults": {
57 | "styleExt": "css",
58 | "component": {}
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/.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 | /dist-server
6 | /tmp
7 | /out-tsc
8 |
9 | # dependencies
10 | /node_modules
11 |
12 | # IDEs and editors
13 | /.idea
14 | .project
15 | .classpath
16 | .c9/
17 | *.launch
18 | .settings/
19 | *.sublime-workspace
20 |
21 | # IDE - VSCode
22 | .vscode/*
23 | !.vscode/settings.json
24 | !.vscode/tasks.json
25 | !.vscode/launch.json
26 | !.vscode/extensions.json
27 |
28 | # misc
29 | /.sass-cache
30 | /connect.lock
31 | /coverage
32 | /libpeerconnection.log
33 | npm-debug.log
34 | testem.log
35 | /typings
36 |
37 | # e2e
38 | /e2e/*.js
39 | /e2e/*.map
40 |
41 | # System Files
42 | .DS_Store
43 | Thumbs.db
44 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "prettier.singleQuote": true,
3 | "typescript.tsdk": "node_modules/typescript/lib"
4 | }
5 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Test Angular
2 |
3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.6.8.
4 |
5 | ## Install dependancies
6 |
7 | Run `npm install`
8 |
9 | ## Start fake JSON Server API
10 |
11 | Run `npm run server` for a server. Navigate to `http://localhost:3000/`.
12 |
13 | ## Development server
14 |
15 | Run `ng serve` for a dev server in a new terminal window. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
16 |
17 | ## Running unit tests
18 |
19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20 |
21 | ## Running end-to-end tests
22 |
23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
24 |
25 | ## Further help
26 |
27 | 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).
28 |
29 |
30 | ## Useful links
31 | - How to configure wallaby for the Angular CLI https://github.com/wallabyjs/ngCliWebpackSample
32 | - JSON Serer docs https://github.com/typicode/json-server
33 | - Angular testing docs https://angular.io/guide/testing
34 | - Jest Angular library docs https://github.com/thymikee/jest-preset-angular
35 |
--------------------------------------------------------------------------------
/db.json:
--------------------------------------------------------------------------------
1 | {
2 | "users": [
3 | {
4 | "id": 1,
5 | "name": "duncan2"
6 | },
7 | {
8 | "id": 2,
9 | "name": "sarah"
10 | },
11 | {
12 | "name": "Mic",
13 | "id": 3
14 | }
15 | ]
16 | }
--------------------------------------------------------------------------------
/e2e/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { AppPage } from './app.po';
2 |
3 | describe('test-angular 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.getParagraphText()).toEqual('Users');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/e2e/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor';
2 |
3 | export class AppPage {
4 | navigateTo() {
5 | return browser.get('/users');
6 | }
7 |
8 | getParagraphText() {
9 | return element(by.css('h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/e2e",
5 | "baseUrl": "./",
6 | "module": "commonjs",
7 | "target": "es6",
8 | "types": [
9 | "jasmine",
10 | "jasminewd2",
11 | "node"
12 | ]
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/e2e/users/users.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { UsersPage } from './users.po';
2 | import { browser } from 'protractor';
3 |
4 | describe('Users Page', () => {
5 | let page: UsersPage;
6 | const EC = browser.ExpectedConditions;
7 |
8 | beforeEach(() => {
9 | page = new UsersPage();
10 | });
11 |
12 | it(`should display title 'Users'`, async () => {
13 | page.navigateTo();
14 | expect(await page.getTitleText()).toEqual('Users');
15 | });
16 |
17 | it(`should edit the first user`, async () => {
18 | page.navigateTo();
19 | await page.getFirstUser().click();
20 | await browser.wait(EC.presenceOf(await page.getInputField()));
21 | await page.getInputField().clear();
22 | await page.getInputField().sendKeys('duncan2');
23 | await page.clickSubmitButton();
24 | await browser.wait(EC.presenceOf(await page.getFirstUser()));
25 | browser.sleep(2000);
26 | const userName = await page.getFirstUser().getText();
27 | expect(userName).toEqual('duncan2');
28 | });
29 |
30 | });
31 |
--------------------------------------------------------------------------------
/e2e/users/users.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor';
2 |
3 | export class UsersPage {
4 | navigateTo() {
5 | return browser.get('/users');
6 | }
7 |
8 | getTitleText() {
9 | return element(by.css('h1')).getText();
10 | }
11 |
12 | getFirstUser() {
13 | return element(by.css('.user-button'));
14 | }
15 |
16 | getInputField() {
17 | return element(by.css('input'));
18 | }
19 |
20 | clickSubmitButton() {
21 | return element(by.css('button')).click();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/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 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular/cli'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular/cli/plugins/karma')
14 | ],
15 | client:{
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | reports: [ 'html', 'lcovonly' ],
20 | fixWebpackSourcePaths: true
21 | },
22 | angularCli: {
23 | environment: 'dev'
24 | },
25 | reporters: ['progress', 'kjhtml'],
26 | port: 9876,
27 | colors: true,
28 | logLevel: config.LOG_INFO,
29 | autoWatch: true,
30 | browsers: ['Chrome'],
31 | singleRun: false
32 | });
33 | };
34 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "test-angular-draft",
3 | "version": "0.0.0",
4 | "license": "MIT",
5 | "scripts": {
6 | "ng": "ng",
7 | "start": "ng serve",
8 | "server": "json-server --watch db.json",
9 | "build": "ng build --prod",
10 | "test": "ng test",
11 | "lint": "ng lint",
12 | "e2e": "ng e2e"
13 | },
14 | "private": true,
15 | "dependencies": {
16 | "@angular/animations": "^5.2.0",
17 | "@angular/common": "^5.2.0",
18 | "@angular/compiler": "^5.2.0",
19 | "@angular/core": "^5.2.0",
20 | "@angular/forms": "^5.2.0",
21 | "@angular/http": "^5.2.0",
22 | "@angular/platform-browser": "^5.2.0",
23 | "@angular/platform-browser-dynamic": "^5.2.0",
24 | "@angular/router": "^5.2.0",
25 | "core-js": "^2.4.1",
26 | "rxjs": "^5.5.6",
27 | "zone.js": "^0.8.19"
28 | },
29 | "devDependencies": {
30 | "@angular/cli": "1.6.8",
31 | "@angular/compiler-cli": "^5.2.0",
32 | "@angular/language-service": "^5.2.0",
33 | "@types/jasmine": "~2.8.3",
34 | "@types/jasminewd2": "~2.0.2",
35 | "@types/node": "~6.0.60",
36 | "angular2-template-loader": "^0.6.2",
37 | "codelyzer": "^4.0.1",
38 | "electron": "^1.8.2",
39 | "jasmine-core": "~2.8.0",
40 | "jasmine-spec-reporter": "~4.2.1",
41 | "karma": "~2.0.0",
42 | "karma-chrome-launcher": "~2.2.0",
43 | "karma-coverage-istanbul-reporter": "^1.2.1",
44 | "karma-jasmine": "~1.1.0",
45 | "karma-jasmine-html-reporter": "^0.2.2",
46 | "protractor": "~5.1.2",
47 | "ts-node": "~4.1.0",
48 | "tslint": "~5.9.1",
49 | "typescript": "~2.5.3",
50 | "wallaby-webpack": "^3.9.4"
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/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 |
6 | exports.config = {
7 | allScriptsTimeout: 11000,
8 | specs: [
9 | './e2e/**/*.e2e-spec.ts'
10 | ],
11 | capabilities: {
12 | 'browserName': 'chrome'
13 | },
14 | directConnect: true,
15 | baseUrl: 'http://localhost:4200/',
16 | framework: 'jasmine',
17 | jasmineNodeOpts: {
18 | showColors: true,
19 | defaultTimeoutInterval: 30000,
20 | print: function() {}
21 | },
22 | onPrepare() {
23 | require('ts-node').register({
24 | project: 'e2e/tsconfig.e2e.json'
25 | });
26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
27 | }
28 | };
29 |
--------------------------------------------------------------------------------
/src/app/app.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/duncanhunter/Pluralsight-Angular-Testing-Play-by-Play/b49160a0fa434e9bffdc3b421920676f2c15cba7/src/app/app.component.css
--------------------------------------------------------------------------------
/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { AppComponent } from './app.component';
2 |
3 | describe(`App Component`, () => {
4 | let component: AppComponent;
5 |
6 | beforeEach(() => {
7 | component = new AppComponent();
8 | });
9 |
10 | it(`should 1 + 1`, () => {
11 | expect(1 + 1).toEqual(2);
12 | });
13 |
14 | it(`should have a component`, () => {
15 | expect(component).toBeTruthy();
16 | });
17 |
18 | it(`should have a title of 'app'`, () => {
19 | expect(component.title).toEqual('app');
20 | });
21 | });
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | // import { TestBed, async } from '@angular/core/testing';
49 | // import { AppComponent } from './app.component';
50 | // describe('AppComponent', () => {
51 | // beforeEach(async(() => {
52 | // TestBed.configureTestingModule({
53 | // declarations: [
54 | // AppComponent
55 | // ],
56 | // }).compileComponents();
57 | // }));
58 | // it('should create the app', async(() => {
59 | // const fixture = TestBed.createComponent(AppComponent);
60 | // const app = fixture.debugElement.componentInstance;
61 | // expect(app).toBeTruthy();
62 | // }));
63 | // it(`should have as title 'app'`, async(() => {
64 | // const fixture = TestBed.createComponent(AppComponent);
65 | // const app = fixture.debugElement.componentInstance;
66 | // expect(app.title).toEqual('app');
67 | // }));
68 | // it('should render title in a h1 tag', async(() => {
69 | // const fixture = TestBed.createComponent(AppComponent);
70 | // fixture.detectChanges();
71 | // const compiled = fixture.debugElement.nativeElement;
72 | // expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
73 | // }));
74 | // });
75 |
--------------------------------------------------------------------------------
/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } 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 {
9 | title = 'app';
10 | }
11 |
--------------------------------------------------------------------------------
/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 |
4 | import { AppComponent } from './app.component';
5 | import { UsersComponent } from './containers/users/users.component';
6 | import { UserListComponent } from './components/user-list/user-list.component';
7 | import { UserEditFormComponent } from './components/user-edit-form/user-edit-form.component';
8 | import { UserComponent } from './containers/user/user.component';
9 | import { HttpClientModule } from '@angular/common/http';
10 | import { RouterModule } from '@angular/router';
11 | import { UserService } from './services/user.service';
12 | import { ReactiveFormsModule } from '@angular/forms';
13 |
14 | @NgModule({
15 | declarations: [
16 | AppComponent,
17 | UsersComponent,
18 | UserListComponent,
19 | UserEditFormComponent,
20 | UserComponent
21 | ],
22 | imports: [
23 | BrowserModule,
24 | HttpClientModule,
25 | ReactiveFormsModule,
26 | RouterModule.forRoot([
27 | { path: '', pathMatch: 'full', redirectTo: 'users' },
28 | { path: 'users', component: UsersComponent },
29 | { path: 'users/:id', component: UserComponent }
30 | ])
31 | ],
32 | providers: [UserService],
33 | bootstrap: [AppComponent]
34 | })
35 | export class AppModule {}
36 |
--------------------------------------------------------------------------------
/src/app/components/user-edit-form/user-edit-form.component.css:
--------------------------------------------------------------------------------
1 | :host {
2 | display: flex;
3 | justify-content: center;
4 | }
5 |
6 | p {
7 | color: red;
8 | }
9 |
10 | input {
11 | padding: 13px;
12 | }
--------------------------------------------------------------------------------
/src/app/components/user-edit-form/user-edit-form.component.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/components/user-edit-form/user-edit-form.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { UserEditFormComponent } from './user-edit-form.component';
4 | import { ReactiveFormsModule } from '../../../../node_modules/@angular/forms';
5 |
6 | describe('UserEditFormComponent', () => {
7 | let component: UserEditFormComponent;
8 | let fixture: ComponentFixture;
9 |
10 | beforeEach(async(() => {
11 | TestBed.configureTestingModule({
12 | imports: [ReactiveFormsModule],
13 | declarations: [UserEditFormComponent]
14 | }).compileComponents();
15 | }));
16 |
17 | beforeEach(() => {
18 | fixture = TestBed.createComponent(UserEditFormComponent);
19 | component = fixture.componentInstance;
20 | fixture.detectChanges();
21 | });
22 |
23 | it('should create', () => {
24 | expect(component).toBeTruthy();
25 | });
26 | });
27 |
--------------------------------------------------------------------------------
/src/app/components/user-edit-form/user-edit-form.component.ts:
--------------------------------------------------------------------------------
1 | import {
2 | Component,
3 | OnInit,
4 | Input,
5 | EventEmitter,
6 | Output,
7 | OnChanges,
8 | SimpleChanges
9 | } from '@angular/core';
10 | import { FormGroup, FormControl, Validators } from '@angular/forms';
11 |
12 | import { User } from '../../models/user';
13 |
14 | @Component({
15 | selector: 'app-user-edit-form',
16 | templateUrl: './user-edit-form.component.html',
17 | styleUrls: ['./user-edit-form.component.css']
18 | })
19 | export class UserEditFormComponent implements OnChanges {
20 | @Output() save = new EventEmitter();
21 | @Input() user: User;
22 |
23 | userForm = new FormGroup({
24 | name: new FormControl('', Validators.required)
25 | });
26 |
27 | ngOnChanges(changes: SimpleChanges): void {
28 | if (changes.user.currentValue) {
29 | this.userForm.patchValue(changes.user.currentValue);
30 | }
31 | }
32 |
33 | submit() {
34 | const updatedUser = {
35 | ...this.user,
36 | name: this.userForm.controls.name.value
37 | };
38 | this.save.emit(updatedUser);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/app/components/user-list/user-list.component.css:
--------------------------------------------------------------------------------
1 | :host {
2 | width: 200px;
3 | border: 1px solid grey;
4 | padding: 5px;
5 | display: flex;
6 | flex-direction: column;
7 | align-items: center;
8 | }
9 |
10 |
11 | .add-button {
12 | margin: 5px;
13 | background-color: #e2e2e2;
14 | color: gray;
15 | border: none;
16 | border-radius: 2px;
17 | padding: 5px;
18 | }
19 |
20 | .title {
21 | display: flex;
22 | flex-direction: row;
23 | }
--------------------------------------------------------------------------------
/src/app/components/user-list/user-list.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Users
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/app/components/user-list/user-list.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 | import { UserListComponent } from './user-list.component';
3 | import { NO_ERRORS_SCHEMA } from '@angular/core';
4 |
5 |
6 | describe('UserListComponent', () => {
7 | let component: UserListComponent;
8 | let fixture: ComponentFixture;
9 |
10 | beforeEach(async(() => {
11 | TestBed.configureTestingModule({
12 | declarations: [ UserListComponent ],
13 | schemas: [ NO_ERRORS_SCHEMA]
14 | })
15 | .compileComponents();
16 | }));
17 |
18 | beforeEach(() => {
19 | fixture = TestBed.createComponent(UserListComponent);
20 | component = fixture.componentInstance;
21 | fixture.detectChanges();
22 | });
23 |
24 | it('should create', () => {
25 | expect(component).toBeTruthy();
26 | });
27 | });
28 |
--------------------------------------------------------------------------------
/src/app/components/user-list/user-list.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, Input } from '@angular/core';
2 | import { User } from '../../models/user';
3 |
4 | @Component({
5 | selector: 'app-user-list',
6 | templateUrl: './user-list.component.html',
7 | styleUrls: ['./user-list.component.css']
8 | })
9 | export class UserListComponent {
10 | @Input() users: User[];
11 | }
12 |
--------------------------------------------------------------------------------
/src/app/containers/user/user.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/duncanhunter/Pluralsight-Angular-Testing-Play-by-Play/b49160a0fa434e9bffdc3b421920676f2c15cba7/src/app/containers/user/user.component.css
--------------------------------------------------------------------------------
/src/app/containers/user/user.component.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/app/containers/user/user.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { UserComponent } from './user.component';
4 | import { NO_ERRORS_SCHEMA } from '@angular/core';
5 | import { RouterTestingModule } from '@angular/router/testing';
6 | import { UserService } from '../../services/user.service';
7 |
8 | describe('UserComponent', () => {
9 | let component: UserComponent;
10 | let fixture: ComponentFixture;
11 |
12 | beforeEach(async(() => {
13 | TestBed.configureTestingModule({
14 | imports: [RouterTestingModule],
15 | declarations: [ UserComponent ],
16 | schemas: [ NO_ERRORS_SCHEMA],
17 | providers: [
18 | {provide: UserService, useValue: jasmine.createSpyObj('userService', ['getUser'])}
19 | ]
20 | })
21 | .compileComponents();
22 | }));
23 |
24 | beforeEach(() => {
25 | fixture = TestBed.createComponent(UserComponent);
26 | component = fixture.componentInstance;
27 | fixture.detectChanges();
28 | });
29 |
30 | it('should create', () => {
31 | expect(component).toBeTruthy();
32 | });
33 | });
34 |
--------------------------------------------------------------------------------
/src/app/containers/user/user.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { UserService } from '../../services/user.service';
3 | import { Observable } from 'rxjs/Observable';
4 | import { User } from '../../models/user';
5 | import { ActivatedRoute, Router } from '@angular/router';
6 |
7 | @Component({
8 | selector: 'app-user',
9 | templateUrl: './user.component.html',
10 | styleUrls: ['./user.component.css']
11 | })
12 | export class UserComponent implements OnInit {
13 | userId: number;
14 | user$: Observable;
15 |
16 | constructor(
17 | private router: Router,
18 | private activatedRoute: ActivatedRoute,
19 | private usersService: UserService) { }
20 |
21 | ngOnInit() {
22 | this.userId = +this.activatedRoute.snapshot.params['id'];
23 | if (this.userId !== 0) {
24 | this.user$ = this.usersService.getUser(this.userId);
25 | }
26 | }
27 |
28 | save(user: User) {
29 | user.id >= 1
30 | ? this.usersService.updatetUser(user).subscribe(() => this.router.navigate(['/users']))
31 | : this.usersService.addUser(user).subscribe(() => this.router.navigate(['/users']));
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/app/containers/users/users.component.css:
--------------------------------------------------------------------------------
1 | :host {
2 | display: flex;
3 | justify-content: center;
4 | }
5 |
--------------------------------------------------------------------------------
/src/app/containers/users/users.component.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/app/containers/users/users.component.spec.ts:
--------------------------------------------------------------------------------
1 | // import { UsersComponent } from './users.component';
2 | // import { of } from 'rxjs/observable/of';
3 | // import { timer } from 'rxjs/observable/timer';
4 | // import { UserService } from '../../services/user.service';
5 | // import { mapTo } from 'rxjs/operators';
6 |
7 | // describe(`Users Component`, () => {
8 | // let component: UsersComponent;
9 | // const fakeUser = {id: 1, name: 'fake'};
10 | // // const fakeUserService = {
11 | // // getUsers: () => of([fakeUser]),
12 | // // httpClient: {}
13 | // // } as any;
14 |
15 | // // const fakeUserService = jasmine.createSpyObj('userService', ['getUsers']);
16 | // const userService = new UserService(null);
17 | // beforeEach(() => {
18 | // component = new UsersComponent(userService);
19 | // });
20 |
21 | // it(`should have a component`, () => {
22 | // expect(component).toBeTruthy();
23 | // });
24 |
25 | // it(`should have a list of users`, () => {
26 | // const spy = spyOn(userService, 'getUsers').and.returnValue(of([fakeUser]));
27 | // component.ngOnInit();
28 | // component.users$.subscribe(users => {
29 | // console.log(users);
30 | // expect(users).toEqual([fakeUser]);
31 | // expect(spy).toHaveBeenCalled();
32 | // expect(spy).toHaveBeenCalledWith();
33 | // expect(spy).toHaveBeenCalledTimes(1);
34 | // });
35 | // });
36 |
37 | // it(`should have a list of users`, (done) => {
38 | // // const spy = spyOn(userService, 'getUsers').and.returnValue(of([fakeUser]));
39 | // const spy = spyOn(userService, 'getUsers').and.returnValue(timer(1000).pipe(mapTo([fakeUser])));
40 | // component.ngOnInit();
41 | // component.users$.subscribe(users => {
42 | // console.log(users);
43 | // expect(users).toEqual([fakeUser]);
44 | // done();
45 | // });
46 | // });
47 | // });
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | import { of } from 'rxjs/observable/of';
67 | import { timer } from 'rxjs/observable/timer';
68 | import { mapTo } from 'rxjs/operators';
69 | import { async, ComponentFixture, TestBed, fakeAsync, discardPeriodicTasks, tick } from '@angular/core/testing';
70 | import { UsersComponent } from './users.component';
71 | import { NO_ERRORS_SCHEMA } from '@angular/core';
72 | import { UserService } from '../../services/user.service';
73 | import { HttpClient } from '@angular/common/http';
74 | import { UserListComponent } from '../../components/user-list/user-list.component';
75 | import { RouterTestingModule } from '@angular/router/testing';
76 | import { By } from '@angular/platform-browser';
77 |
78 | describe('UsersComponent', () => {
79 | let component: UsersComponent;
80 | let fixture: ComponentFixture;
81 | let userService: UserService;
82 | const fakeUser = { id: 1, name: 'fake' };
83 |
84 | beforeEach(async(() => {
85 | TestBed.configureTestingModule({
86 | imports: [RouterTestingModule],
87 | declarations: [UsersComponent, UserListComponent],
88 | providers: [
89 | UserService,
90 | { provide: HttpClient, useValue: {} }],
91 | schemas: [NO_ERRORS_SCHEMA]
92 | })
93 | .compileComponents();
94 | }));
95 |
96 | beforeEach(() => {
97 | fixture = TestBed.createComponent(UsersComponent);
98 | component = fixture.componentInstance;
99 | userService = TestBed.get(UserService);
100 | // fixture.detectChanges();
101 | });
102 |
103 | it('should create', () => {
104 | expect(component).toBeTruthy();
105 | });
106 |
107 | it(`should have a list of users`, (done) => {
108 | // const spy = spyOn(userService, 'getUsers').and.returnValue(of([fakeUser]));
109 | const spy = spyOn(userService, 'getUsers').and.returnValue(timer(1000).pipe(mapTo([fakeUser])));
110 | component.ngOnInit();
111 | component.users$.subscribe(users => {
112 | console.log(users);
113 | expect(users).toEqual([fakeUser]);
114 | done();
115 | });
116 | });
117 |
118 | it(`should have a list of users`, async(() => {
119 | // const spy = spyOn(userService, 'getUsers').and.returnValue(of([fakeUser]));
120 | const spy = spyOn(userService, 'getUsers').and.returnValue(timer(1000).pipe(mapTo([fakeUser])));
121 | component.ngOnInit();
122 | fixture.detectChanges();
123 | component.users$.subscribe(users => {
124 | // console.log(users);
125 | // console.log(document.querySelector('app-user-list').innerHTML);
126 | expect(users).toEqual([fakeUser]);
127 | });
128 |
129 | fixture.whenStable().then(() => {
130 | fixture.detectChanges();
131 | const buttons = fixture.debugElement.queryAll(By.css('.user-button'));
132 | expect(buttons[0].nativeElement.textContent).toEqual('fake');
133 | });
134 |
135 | }));
136 | });
137 |
--------------------------------------------------------------------------------
/src/app/containers/users/users.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { Observable } from 'rxjs/Observable';
3 | import { User } from '../../models/user';
4 | import { UserService } from '../../services/user.service';
5 |
6 | @Component({
7 | selector: 'app-users',
8 | templateUrl: './users.component.html',
9 | styleUrls: ['./users.component.css']
10 | })
11 | export class UsersComponent implements OnInit {
12 | users$: Observable;
13 |
14 | constructor(private usersService: UserService) { }
15 |
16 | ngOnInit() {
17 | this.users$ = this.usersService.getUsers();
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/app/models/user.ts:
--------------------------------------------------------------------------------
1 | export interface User {
2 | id?: number;
3 | name: string;
4 | }
5 |
--------------------------------------------------------------------------------
/src/app/services/user.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, inject } from '@angular/core/testing';
2 |
3 | import { UserService } from './user.service';
4 | import { HttpClient } from '../../../node_modules/@angular/common/http';
5 |
6 | describe('UserService', () => {
7 | beforeEach(() => {
8 | TestBed.configureTestingModule({
9 | providers: [
10 | UserService,
11 | {provide: HttpClient , userValue: {}}
12 | ]
13 | });
14 | });
15 |
16 | it('should be created', inject([UserService], (service: UserService) => {
17 | expect(service).toBeTruthy();
18 | }));
19 | });
20 |
--------------------------------------------------------------------------------
/src/app/services/user.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { User } from './../models/user';
3 | import { Observable } from 'rxjs/Observable';
4 | import { HttpClient } from '@angular/common/http';
5 | import { catchError } from 'rxjs/operators';
6 | import { of } from 'rxjs/observable/of';
7 |
8 | @Injectable()
9 | export class UserService {
10 |
11 | constructor(private httpClient: HttpClient) { }
12 |
13 | getUser(id: number): Observable {
14 | return this.httpClient.get(`http://localhost:3000/users/${id}`)
15 | .pipe(catchError(this.handleError('getUsers id=${id}')));
16 | }
17 |
18 | getUsers(): Observable {
19 | return this.httpClient.get(`http://localhost:3000/users`)
20 | .pipe(catchError(this.handleError('getUsers', [])));
21 | }
22 |
23 | updatetUser(user: User): Observable {
24 | return this.httpClient.put(`http://localhost:3000/users/${user.id}`, user)
25 | .pipe(catchError(this.handleError('update User')));
26 | }
27 |
28 | addUser(user: User): Observable {
29 | return this.httpClient.post(`http://localhost:3000/users`, user)
30 | .pipe(catchError(this.handleError('add User')));
31 | }
32 |
33 |
34 | private handleError(operation = 'operation', result?: T) {
35 | return (error: any): Observable => {
36 | console.error(error); // log to console instead
37 | console.log(`${operation} failed: ${error.message}`);
38 | return of(result as T);
39 | };
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/duncanhunter/Pluralsight-Angular-Testing-Play-by-Play/b49160a0fa434e9bffdc3b421920676f2c15cba7/src/assets/.gitkeep
--------------------------------------------------------------------------------
/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/duncanhunter/Pluralsight-Angular-Testing-Play-by-Play/b49160a0fa434e9bffdc3b421920676f2c15cba7/src/favicon.ico
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | TestAngularDraft
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/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().bootstrapModule(AppModule)
12 | .catch(err => console.log(err));
13 |
--------------------------------------------------------------------------------
/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 |
44 | /** Evergreen browsers require these. **/
45 | // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
46 | import 'core-js/es7/reflect';
47 |
48 |
49 | /**
50 | * Required to support Web Animations `@angular/platform-browser/animations`.
51 | * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
52 | **/
53 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
54 |
55 |
56 |
57 | /***************************************************************************************************
58 | * Zone JS is required by default for Angular itself.
59 | */
60 | import 'zone.js/dist/zone'; // Included with Angular CLI.
61 |
62 |
63 |
64 | /***************************************************************************************************
65 | * APPLICATION IMPORTS
66 | */
67 |
--------------------------------------------------------------------------------
/src/styles.css:
--------------------------------------------------------------------------------
1 | html * {
2 | font-size: large;
3 | font-family: roboto, sans-serif
4 | }
5 |
6 | button {
7 | margin: 10px 0;
8 | background-color: #00afee;
9 | color: white;
10 | border: none;
11 | border-radius: 2px;
12 | padding: 15px;
13 | }
--------------------------------------------------------------------------------
/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/zone-testing';
4 | import { getTestBed } from '@angular/core/testing';
5 | import {
6 | BrowserDynamicTestingModule,
7 | platformBrowserDynamicTesting
8 | } from '@angular/platform-browser-dynamic/testing';
9 |
10 | declare const require: any;
11 |
12 | // First, initialize the Angular testing environment.
13 | getTestBed().initTestEnvironment(
14 | BrowserDynamicTestingModule,
15 | platformBrowserDynamicTesting()
16 | );
17 | // Then we find all the tests.
18 | const context = require.context('./', true, /\.spec\.ts$/);
19 | // And load the modules.
20 | context.keys().map(context);
21 |
--------------------------------------------------------------------------------
/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "baseUrl": "./",
6 | "module": "es2015",
7 | "types": []
8 | },
9 | "exclude": [
10 | "test.ts",
11 | "**/*.spec.ts",
12 | "wallabyTest.ts"
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "baseUrl": "./",
6 | "module": "commonjs",
7 | "types": [
8 | "jasmine",
9 | "node"
10 | ]
11 | },
12 | "files": [
13 | "test.ts"
14 | ],
15 | "include": [
16 | "**/*.spec.ts",
17 | "**/*.d.ts"
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/src/typings.d.ts:
--------------------------------------------------------------------------------
1 | /* SystemJS module definition */
2 | declare var module: NodeModule;
3 | interface NodeModule {
4 | id: string;
5 | }
6 |
--------------------------------------------------------------------------------
/src/wallabyTest.ts:
--------------------------------------------------------------------------------
1 | import './polyfills';
2 |
3 | import 'zone.js/dist/long-stack-trace-zone';
4 | import 'zone.js/dist/proxy.js';
5 | import 'zone.js/dist/sync-test';
6 | import 'zone.js/dist/jasmine-patch';
7 | import 'zone.js/dist/async-test';
8 | import 'zone.js/dist/fake-async-test';
9 |
10 | import { getTestBed } from '@angular/core/testing';
11 | import {
12 | BrowserDynamicTestingModule,
13 | platformBrowserDynamicTesting
14 | } from '@angular/platform-browser-dynamic/testing';
15 |
16 | getTestBed().initTestEnvironment(
17 | BrowserDynamicTestingModule,
18 | platformBrowserDynamicTesting()
19 | );
20 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "outDir": "./dist/out-tsc",
5 | "sourceMap": true,
6 | "declaration": false,
7 | "moduleResolution": "node",
8 | "emitDecoratorMetadata": true,
9 | "experimentalDecorators": true,
10 | "target": "es5",
11 | "typeRoots": [
12 | "node_modules/@types"
13 | ],
14 | "lib": [
15 | "es2017",
16 | "dom"
17 | ]
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rulesDirectory": [
3 | "node_modules/codelyzer"
4 | ],
5 | "rules": {
6 | "arrow-return-shorthand": true,
7 | "callable-types": true,
8 | "class-name": true,
9 | "comment-format": [
10 | true,
11 | "check-space"
12 | ],
13 | "curly": true,
14 | "deprecation": {
15 | "severity": "warn"
16 | },
17 | "eofline": true,
18 | "forin": true,
19 | "import-blacklist": [
20 | true,
21 | "rxjs",
22 | "rxjs/Rx"
23 | ],
24 | "import-spacing": true,
25 | "indent": [
26 | true,
27 | "spaces"
28 | ],
29 | "interface-over-type-literal": true,
30 | "label-position": true,
31 | "max-line-length": [
32 | true,
33 | 140
34 | ],
35 | "member-access": false,
36 | "member-ordering": [
37 | true,
38 | {
39 | "order": [
40 | "static-field",
41 | "instance-field",
42 | "static-method",
43 | "instance-method"
44 | ]
45 | }
46 | ],
47 | "no-arg": true,
48 | "no-bitwise": true,
49 | "no-console": [
50 | true,
51 | "debug",
52 | "info",
53 | "time",
54 | "timeEnd",
55 | "trace"
56 | ],
57 | "no-construct": true,
58 | "no-debugger": true,
59 | "no-duplicate-super": true,
60 | "no-empty": false,
61 | "no-empty-interface": true,
62 | "no-eval": true,
63 | "no-inferrable-types": [
64 | true,
65 | "ignore-params"
66 | ],
67 | "no-misused-new": true,
68 | "no-non-null-assertion": true,
69 | "no-shadowed-variable": true,
70 | "no-string-literal": false,
71 | "no-string-throw": true,
72 | "no-switch-case-fall-through": true,
73 | "no-trailing-whitespace": true,
74 | "no-unnecessary-initializer": true,
75 | "no-unused-expression": true,
76 | "no-use-before-declare": true,
77 | "no-var-keyword": true,
78 | "object-literal-sort-keys": false,
79 | "one-line": [
80 | true,
81 | "check-open-brace",
82 | "check-catch",
83 | "check-else",
84 | "check-whitespace"
85 | ],
86 | "prefer-const": true,
87 | "quotemark": [
88 | true,
89 | "single"
90 | ],
91 | "radix": true,
92 | "semicolon": [
93 | true,
94 | "always"
95 | ],
96 | "triple-equals": [
97 | true,
98 | "allow-null-check"
99 | ],
100 | "typedef-whitespace": [
101 | true,
102 | {
103 | "call-signature": "nospace",
104 | "index-signature": "nospace",
105 | "parameter": "nospace",
106 | "property-declaration": "nospace",
107 | "variable-declaration": "nospace"
108 | }
109 | ],
110 | "unified-signatures": true,
111 | "variable-name": false,
112 | "whitespace": [
113 | true,
114 | "check-branch",
115 | "check-decl",
116 | "check-operator",
117 | "check-separator",
118 | "check-type"
119 | ],
120 | "directive-selector": [
121 | true,
122 | "attribute",
123 | "app",
124 | "camelCase"
125 | ],
126 | "component-selector": [
127 | true,
128 | "element",
129 | "app",
130 | "kebab-case"
131 | ],
132 | "no-output-on-prefix": true,
133 | "use-input-property-decorator": true,
134 | "use-output-property-decorator": true,
135 | "use-host-property-decorator": true,
136 | "no-input-rename": true,
137 | "no-output-rename": true,
138 | "use-life-cycle-interface": true,
139 | "use-pipe-transform-interface": true,
140 | "component-class-suffix": true,
141 | "directive-class-suffix": true
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/wallaby.js:
--------------------------------------------------------------------------------
1 | var wallabyWebpack = require('wallaby-webpack');
2 | var path = require('path');
3 |
4 | var compilerOptions = Object.assign(
5 | require('./tsconfig.json').compilerOptions,
6 | require('./src/tsconfig.spec.json').compilerOptions);
7 |
8 | compilerOptions.module = 'CommonJs';
9 |
10 | module.exports = function (wallaby) {
11 |
12 | var webpackPostprocessor = wallabyWebpack({
13 | entryPatterns: [
14 | 'src/wallabyTest.js',
15 | 'src/**/*spec.js'
16 | ],
17 |
18 | module: {
19 | rules: [
20 | {test: /\.css$/, loader: ['raw-loader', 'css-loader']},
21 | {test: /\.html$/, loader: 'raw-loader'},
22 | {test: /\.ts$/, loader: '@ngtools/webpack', include: /node_modules/, query: {tsConfigPath: 'tsconfig.json'}},
23 | {test: /\.js$/, loader: 'angular2-template-loader', exclude: /node_modules/},
24 | {test: /\.json$/, loader: 'json-loader'},
25 | {test: /\.styl$/, loaders: ['raw-loader', 'stylus-loader']},
26 | {test: /\.less$/, loaders: ['raw-loader', 'less-loader']},
27 | {test: /\.scss$|\.sass$/, loaders: ['raw-loader', 'sass-loader']},
28 | {test: /\.(jpg|png)$/, loader: 'url-loader?limit=128000'}
29 | ]
30 | },
31 |
32 | resolve: {
33 | extensions: ['.js', '.ts'],
34 | modules: [
35 | path.join(wallaby.projectCacheDir, 'src/app'),
36 | path.join(wallaby.projectCacheDir, 'src'),
37 | 'node_modules'
38 | ]
39 | },
40 | node: {
41 | fs: 'empty',
42 | net: 'empty',
43 | tls: 'empty',
44 | dns: 'empty'
45 | }
46 | });
47 |
48 | return {
49 | files: [
50 | {pattern: 'src/**/*.+(ts|css|less|scss|sass|styl|html|json|svg)', load: false},
51 | {pattern: 'src/**/*.d.ts', ignore: true},
52 | {pattern: 'src/**/*spec.ts', ignore: true}
53 | ],
54 |
55 | tests: [
56 | {pattern: 'src/**/*spec.ts', load: false},
57 | {pattern: 'src/**/*e2e-spec.ts', ignore: true}
58 | ],
59 |
60 | testFramework: 'jasmine',
61 |
62 | compilers: {
63 | '**/*.ts': wallaby.compilers.typeScript(compilerOptions)
64 | },
65 |
66 | middleware: function (app, express) {
67 | var path = require('path');
68 | app.use('/favicon.ico', express.static(path.join(__dirname, 'src/favicon.ico')));
69 | app.use('/assets', express.static(path.join(__dirname, 'src/assets')));
70 | },
71 |
72 | env: {
73 | kind: 'electron'
74 | },
75 |
76 | postprocessor: webpackPostprocessor,
77 |
78 | setup: function () {
79 | window.__moduleBundler.loadTests();
80 | },
81 |
82 | debug: true
83 | };
84 | };
85 |
--------------------------------------------------------------------------------