Commit ae05ea5a authored by 神楽坂玲奈's avatar 神楽坂玲奈

Init

parent 182d81a3
## Angular Documentation QuickStart Changelog
Upgraders: for a fresh start, consider running these commands
* `git clean -xdf`
* `npm install`
<a name="0.2.22"></a>
# 0.2.22 (2017-01-05)
* Add `non-essential-files.txt` and instructions to use it to README
<a name="0.2.21"></a>
# 0.2.21 (2016-12-14)
* Update to in-memory-web-api v.0.2.1
<a name="0.2.20"></a>
# 0.2.20 (2016-12-07)
* Update to Angular 2.3.0
<a name="0.2.19"></a>
# 0.2.19 (2016-11-30)
* remove upgrade mappings from `systemjs.config.js` PR #301
<a name="0.2.18"></a>
# 0.2.18 (2016-11-30)
* remove `exclude` clause from `tsconfig.json`; it was just confusing people
* karma.config + karma-test-shim can handle multiple spec source paths (issue #294)
* cosmetic `app.component.spec.ts` changes
* cosmetic `karma.config.js` changes
<a name="0.2.17"></a>
# 0.2.17 (2016-11-16)
* Conform to updated QuickStart advice
* removed docker everywhere (was nice but not necessary)
* removed wallaby
* shrink styles.css
* refine tsconfig.json
* `AppComponent` uses interpolation
<a name="0.2.16"></a>
# 0.2.16 (2016-11-14)
* Update to Angular 2.2.0
<a name="0.2.15"></a>
# 0.2.15 (2016-10-29)
* Revert to Jasmine 2.4.1 because bug in 2.5.x (see [jasmine issue #1231](https://github.com/jasmine/jasmine/issues/1231))
<a name="0.2.14"></a>
# 0.2.14 (2016-10-29)
* Remove bootstrap.css install
* Angular v2.1.2
<a name="0.2.13"></a>
# 0.2.13 (2016-10-20)
* Protractor 4
* Move from `typings` to `@types`. See `tsconfig.json` changes.
* Angular v2.1.1
<a name="0.2.12"></a>
# 0.2.12 (2016-10-06)
* Angular v2.1.0
<a name="0.2.11"></a>
# 0.2.11 (2016-10-06)
* Angular v2.0.2
* License is MIT
* Current testing configuration
* No code changes
<a name="0.2.10"></a>
# 0.2.10 (2016-09-19)
* All "Angular 2" references become just "Angular"
* No code changes
<a name="0.2.9"></a>
# 0.2.9 (2016-09-14)
* Angular 2.0.0 version
* Update to Typescript 2.0.2
* Fix e2e test missing dir
<a name="0.2.8"></a>
# 0.2.8 (2016-09-01)
* remove @angular test libraries from system.js (now in shim)
* update test related files
* wallaby doesn't completely work. Researching.
<a name="0.2.7"></a>
# 0.2.7 (2016-08-31)
* Angular 2 RC6 version
* Updated new forms, router, angular2-in-memory-web-api, karma, core-js, rxjs and zone.js packages
* Removed router-deprecated package
* Updated karma.conf.js and systemjs.config.js
<a name="0.2.6"></a>
# 0.2.6 (2016-08-09)
* Angular 2 RC5 version
* Updated new forms, router and angular2-in-memory-web-api
<a name="0.2.5"></a>
# 0.2.5 (2016-06-30)
* Angular 2 RC4 version
* Updated new forms and router
<a name="0.2.4"></a>
# 0.2.4 (2016-06-21)
* Angular 2 RC3 version
* Add new forms and router
* Add support for TS e2e tests
<a name="0.2.3"></a>
# 0.2.3 (2016-06-15)
* Angular 2 RC2 version
<a name="0.2.2"></a>
# 0.2.2 (2016-05-21)
* Update to Typings 1.x
<a name="0.2.1"></a>
# 0.2.1 (2016-05-03)
* Angular 2 RC01 version
<a name="0.2.0"></a>
# 0.2.0 (2016-05-02)
* Angular 2 RC0 version
<a name="0.1.17"></a>
# 0.1.17 (2016-04-29)
* update packages
* Angular 2 beta 17
* RxJS 5.0.0-beta.6
* a2-in-memory-web-api 0.1.17
<a name="0.1.16"></a>
# 0.1.16 (2016-04-26)
* update packages
* Angular 2 beta 16
* a2-in-memory-web-api 0.1.6
* protractor 3.3.0
* typings 0.8.1
* zone.js 0.6.12
* added favicon.ico
* testing
- updated wallaby.js and karma.conf.js
- updated app.component.spec.ts
<a name="0.1.15"></a>
# 0.1.15 (2016-04-13)
* Add testing support
* npm scripts
* karma/jasmine
* protractor
* update packages
* Angular 2 beta 15
* lite-server 2.2.0
* systemjs 0.19.26
* typescript 1.8.10
* typings 0.7.12
* add run packages
* a2-in-memory-web-api
* add testing dev-dependency packages
* canonical-path: 0.0.2,
* http-server: ^0.9.0,
* jasmine-core: ~2.4.1,
* karma: ^0.13.22,
* karma-chrome-launcher: ^0.2.3,
* karma-cli: ^0.1.2,
* karma-htmlfile-reporter: ^0.2.2,
* karma-jasmine: ^0.3.8,
* protractor: ^3.2.2,
* rimraf: ^2.5.2
<a name="0.1.14"></a>
# 0.1.14 (2016-04-07)
* update packages
* Angular 2 beta 14
* lite-server 2.2.0
* typings 0.7.12
<a name="0.1.13"></a>
# 0.1.13 (2016-03-31)
* update packages
* Angular 2 beta 13
<a name="0.1.12"></a>
# 0.1.12 (2016-03-23)
* update packages
* Angular 2 beta 12
* zones 0.6.6
* remove es6-promise because no longer needed.
<a name="0.1.11"></a>
# 0.1.11 (2016-03-18)
* update packages
* Angular 2 beta 11
* zones 0.6.4
* typescript 1.8.9
* typings 0.7.9
import { AppComponent } from './app.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
describe('AppComponent', function () {
let de: DebugElement;
let comp: AppComponent;
let fixture: ComponentFixture<AppComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AppComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AppComponent);
comp = fixture.componentInstance;
de = fixture.debugElement.query(By.css('h1'));
});
it('should create component', () => expect(comp).toBeDefined() );
it('should have expected <h1> text', () => {
fixture.detectChanges();
const h1 = de.nativeElement;
expect(h1.innerText).toMatch(/angular/i,
'<h1> should say something about "Angular"');
});
});
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: `<h1>Hello {{name}}</h1>`,
})
export class AppComponent { name = 'Angular'; }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; window['jQuery'] = require('jquery');
window['Tether'] = require('tether');
import 'bootstrap';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {StoreModule} from './store.module';
import { AppModule } from './app.module'; platformBrowserDynamic().bootstrapModule(StoreModule);
platformBrowserDynamic().bootstrapModule(AppModule);
<nav class="navbar navbar-toggleable-md navbar-inverse fixed-top bg-inverse">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">Navbar</a>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="http://example.com" id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown</a>
<div class="dropdown-menu" aria-labelledby="dropdown01">
<a class="dropdown-item" href="#">Action</a> <a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="jumbotron">
<div class="container">
<div class="row">
<div class="col">
<h1 class="display-3">萌卡喵</h1>
<p>这里是一段介绍</p>
<p>
<a class="btn btn-primary btn-lg" href="#" role="button">立即安装</a>
</p>
<p>
同时适用于 <a href="#">Windows</a><a href="#">Linux</a></p>
</div>
<div class="col">
<img src="http://i.zgjm.org/uploads/allimg/140118/1334551250-0.jpg">
</div>
</div>
</div>
</div>
<div class="container">
<!-- Example row of columns -->
<div class="row">
<div class="col-md-6">
<h2>Heading</h2>
<p>用户数 {{signups}}</p>
<p><a class="btn btn-secondary" href="#" role="button">View details &raquo;</a></p>
</div>
<div class="col-md-6">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-secondary" href="#" role="button">View details &raquo;</a></p>
</div>
<div class="col-md-6">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<p><a class="btn btn-secondary" href="#" role="button">View details &raquo;</a></p>
</div>
<div class="col-md-6">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<p><a class="btn btn-secondary" href="#" role="button">View details &raquo;</a></p>
</div>
</div>
<div class="row">
<div class="col">
<p>那么,您还在犹豫什么呢?</p>
<a class="btn btn-primary btn-lg" href="#" role="button">立即安装</a>
</div>
<div>
<p>系统需求</p>
<p>Windows 7、8 或 10</p>
<p>1G 内存</p>
<p>1 Ghz 或更快的处理器</p>
<p>Mac OS X 版本 10.12 (Sierra) 或更新的版本。</p>
<p>强烈推荐使用双键鼠标</p>
<p>1GB 硬盘空间</p>
<p>互联网连接</p>
</div>
</div>
<hr>
<footer>
<p>&copy; Company 2017</p>
</footer>
</div> <!-- /container -->
import {Component, OnInit} from '@angular/core';
import {Http, URLSearchParams} from '@angular/http';
import 'rxjs/Rx';
@Component({
moduleId: module.id,
selector: 'store',
templateUrl: 'store.component.html',
styleUrls: ['store.component.css'],
})
export class StoreComponent implements OnInit {
signups: number;
constructor (private http: Http) {
}
async ngOnInit () {
let params = new URLSearchParams();
params.set('api_key', 'dc7298a754828b3d26b709f035a0eeceb43e73cbd8c4fa8dec18951f8a95d2bc');
params.set('api_username', 'zh99998');
let data = await this.http.get('https://ygobbs.com/admin/dashboard.json', {search: params})
.map(response => response.json()).toPromise();
this.signups = data.global_reports.find((item: any) => item.type === 'signups').total;
}
}
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component'; import { StoreComponent } from './store.component';
import {HttpModule} from '@angular/http';
@NgModule({ @NgModule({
imports: [ BrowserModule ], imports: [ BrowserModule, HttpModule ],
declarations: [ AppComponent ], declarations: [ StoreComponent ],
bootstrap: [ AppComponent ] bootstrap: [ StoreComponent ]
}) })
export class AppModule { } export class StoreModule { }
import { browser, element, by } from 'protractor';
describe('QuickStart E2E Tests', function () {
let expectedMsg = 'Hello Angular';
beforeEach(function () {
browser.get('');
});
it('should display: ' + expectedMsg, function () {
expect(element(by.css('h1')).getText()).toEqual(expectedMsg);
});
});
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
<head> <head>
<title>Angular QuickStart</title> <title>Angular QuickStart</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="styles.css"> <link rel="stylesheet" href="styles.css">
<!-- Polyfill(s) for older browsers --> <!-- Polyfill(s) for older browsers -->
...@@ -19,6 +20,6 @@ ...@@ -19,6 +20,6 @@
</head> </head>
<body> <body>
<my-app>Loading AppComponent content here ...</my-app> <store>Loading AppComponent content here ...</store>
</body> </body>
</html> </html>
// /*global jasmine, __karma__, window*/
Error.stackTraceLimit = 0; // "No stacktrace"" is usually best for app testing.
// Uncomment to get full stacktrace output. Sometimes helpful, usually not.
// Error.stackTraceLimit = Infinity; //
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
// builtPaths: root paths for output ("built") files
// get from karma.config.js, then prefix with '/base/' (default is 'app/')
var builtPaths = (__karma__.config.builtPaths || ['app/'])
.map(function(p) { return '/base/'+p;});
__karma__.loaded = function () { };
function isJsFile(path) {
return path.slice(-3) == '.js';
}
function isSpecFile(path) {
return /\.spec\.(.*\.)?js$/.test(path);
}
// Is a "built" file if is JavaScript file in one of the "built" folders
function isBuiltFile(path) {
return isJsFile(path) &&
builtPaths.reduce(function(keep, bp) {
return keep || (path.substr(0, bp.length) === bp);
}, false);
}
var allSpecFiles = Object.keys(window.__karma__.files)
.filter(isSpecFile)
.filter(isBuiltFile);
System.config({
baseURL: 'base',
// Extend usual application package list with test folder
packages: { 'testing': { main: 'index.js', defaultExtension: 'js' } },
// Assume npm: is set in `paths` in systemjs.config
// Map the angular testing umd bundles
map: {
'@angular/core/testing': 'npm:@angular/core/bundles/core-testing.umd.js',
'@angular/common/testing': 'npm:@angular/common/bundles/common-testing.umd.js',
'@angular/compiler/testing': 'npm:@angular/compiler/bundles/compiler-testing.umd.js',
'@angular/platform-browser/testing': 'npm:@angular/platform-browser/bundles/platform-browser-testing.umd.js',
'@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js',
'@angular/http/testing': 'npm:@angular/http/bundles/http-testing.umd.js',
'@angular/router/testing': 'npm:@angular/router/bundles/router-testing.umd.js',
'@angular/forms/testing': 'npm:@angular/forms/bundles/forms-testing.umd.js',
},
});
System.import('systemjs.config.js')
.then(importSystemJsExtras)
.then(initTestBed)
.then(initTesting);
/** Optional SystemJS configuration extras. Keep going w/o it */
function importSystemJsExtras(){
return System.import('systemjs.config.extras.js')
.catch(function(reason) {
console.log(
'Warning: System.import could not load the optional "systemjs.config.extras.js". Did you omit it by accident? Continuing without it.'
);
console.log(reason);
});
}
function initTestBed(){
return Promise.all([
System.import('@angular/core/testing'),
System.import('@angular/platform-browser-dynamic/testing')
])
.then(function (providers) {
var coreTesting = providers[0];
var browserTesting = providers[1];
coreTesting.TestBed.initTestEnvironment(
browserTesting.BrowserDynamicTestingModule,
browserTesting.platformBrowserDynamicTesting());
})
}
// Import all spec files and start karma
function initTesting () {
return Promise.all(
allSpecFiles.map(function (moduleName) {
return System.import(moduleName);
})
)
.then(__karma__.start, __karma__.error);
}
module.exports = function(config) {
var appBase = 'app/'; // transpiled app JS and map files
var appSrcBase = 'app/'; // app source TS files
var appAssets = '/base/app/'; // component assets fetched by Angular's compiler
// Testing helpers (optional) are conventionally in a folder called `testing`
var testingBase = 'testing/'; // transpiled test JS and map files
var testingSrcBase = 'testing/'; // test source TS files
config.set({
basePath: '',
frameworks: ['jasmine'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter')
],
client: {
builtPaths: [appBase, testingBase], // add more spec base paths as needed
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
customLaunchers: {
// From the CLI. Not used here but interesting
// chrome setup for travis CI using chromium
Chrome_travis_ci: {
base: 'Chrome',
flags: ['--no-sandbox']
}
},
files: [
// System.js for module loading
'node_modules/systemjs/dist/system.src.js',
// Polyfills
'node_modules/core-js/client/shim.js',
// zone.js
'node_modules/zone.js/dist/zone.js',
'node_modules/zone.js/dist/long-stack-trace-zone.js',
'node_modules/zone.js/dist/proxy.js',
'node_modules/zone.js/dist/sync-test.js',
'node_modules/zone.js/dist/jasmine-patch.js',
'node_modules/zone.js/dist/async-test.js',
'node_modules/zone.js/dist/fake-async-test.js',
// RxJs
{ pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
{ pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },
// Paths loaded via module imports:
// Angular itself
{ pattern: 'node_modules/@angular/**/*.js', included: false, watched: false },
{ pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false },
{ pattern: 'systemjs.config.js', included: false, watched: false },
{ pattern: 'systemjs.config.extras.js', included: false, watched: false },
'karma-test-shim.js', // optionally extend SystemJS mapping e.g., with barrels
// transpiled application & spec code paths loaded via module imports
{ pattern: appBase + '**/*.js', included: false, watched: true },
{ pattern: testingBase + '**/*.js', included: false, watched: true },
// Asset (HTML & CSS) paths loaded via Angular's component compiler
// (these paths need to be rewritten, see proxies section)
{ pattern: appBase + '**/*.html', included: false, watched: true },
{ pattern: appBase + '**/*.css', included: false, watched: true },
// Paths for debugging with source maps in dev tools
{ pattern: appSrcBase + '**/*.ts', included: false, watched: false },
{ pattern: appBase + '**/*.js.map', included: false, watched: false },
{ pattern: testingSrcBase + '**/*.ts', included: false, watched: false },
{ pattern: testingBase + '**/*.js.map', included: false, watched: false}
],
// Proxied base paths for loading assets
proxies: {
// required for component assets fetched by Angular's compiler
"/app/": appAssets
},
exclude: [],
preprocessors: {},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
})
}
.git
.gitignore
.travis.yml
*.spec*.ts
CHANGELOG.md
e2e
favicon.ico
karma.conf.js
karma-test-shim.js
LICENSE
non-essential-files.txt
protractor.config.js
README.md
{ {
"name": "angular-quickstart", "name": "mycard-store",
"version": "1.0.0", "version": "1.0.0",
"description": "QuickStart package.json from the documentation, supplemented with testing support", "description": "QuickStart package.json from the documentation, supplemented with testing support",
"scripts": { "scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ", "start": "tsc && lite-server",
"e2e": "tsc && concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first", "e2e": "tsc && concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first",
"lint": "tslint ./app/**/*.ts -t verbose", "lint": "tslint ./app/**/*.ts -t verbose",
"lite": "lite-server", "lite": "lite-server",
...@@ -15,43 +15,32 @@ ...@@ -15,43 +15,32 @@
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",
"license": "MIT", "license": "UNLICENSED",
"dependencies": { "dependencies": {
"@angular/common": "~2.4.0", "@angular/common": "latest",
"@angular/compiler": "~2.4.0", "@angular/compiler": "latest",
"@angular/core": "~2.4.0", "@angular/core": "latest",
"@angular/forms": "~2.4.0", "@angular/forms": "latest",
"@angular/http": "~2.4.0", "@angular/http": "latest",
"@angular/platform-browser": "~2.4.0", "@angular/platform-browser": "latest",
"@angular/platform-browser-dynamic": "~2.4.0", "@angular/platform-browser-dynamic": "latest",
"@angular/router": "~3.4.0", "@angular/router": "latest",
"@types/bootstrap": "latest",
"angular-in-memory-web-api": "~0.2.4", "@types/jquery": "latest",
"systemjs": "0.19.40", "@types/tether": "latest",
"core-js": "^2.4.1", "angular-in-memory-web-api": "latest",
"rxjs": "5.0.1", "bootstrap": "next",
"core-js": "latest",
"jquery": "latest",
"rxjs": "latest",
"systemjs": "latest",
"tether": "latest",
"zone.js": "^0.7.4" "zone.js": "^0.7.4"
}, },
"devDependencies": { "devDependencies": {
"concurrently": "^3.1.0", "lite-server": "latest",
"lite-server": "^2.2.2", "typescript": "latest",
"typescript": "~2.0.10", "tslint": "^3.15.1"
"canonical-path": "0.0.2",
"http-server": "^0.9.0",
"tslint": "^3.15.1",
"lodash": "^4.16.4",
"jasmine-core": "~2.4.1",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~4.0.14",
"rimraf": "^2.5.4",
"@types/node": "^6.0.46",
"@types/jasmine": "^2.5.36"
}, },
"repository": {} "repository": {}
} }
// FIRST TIME ONLY- run:
// ./node_modules/.bin/webdriver-manager update
//
// Try: `npm run webdriver:update`
//
// AND THEN EVERYTIME ...
// 1. Compile with `tsc`
// 2. Make sure the test server (e.g., http-server: localhost:8080) is running.
// 3. ./node_modules/.bin/protractor protractor.config.js
//
// To do all steps, try: `npm run e2e`
var fs = require('fs');
var path = require('canonical-path');
var _ = require('lodash');
exports.config = {
directConnect: true,
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},
// Framework to use. Jasmine is recommended.
framework: 'jasmine',
// Spec patterns are relative to this config file
specs: ['**/*e2e-spec.js' ],
// For angular tests
useAllAngular2AppRoots: true,
// Base URL for application server
baseUrl: 'http://localhost:8080',
// doesn't seem to work.
// resultJsonOutputFile: "foo.json",
onPrepare: function() {
//// SpecReporter
//var SpecReporter = require('jasmine-spec-reporter');
//jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'none'}));
//// jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'}));
// debugging
// console.log('browser.params:' + JSON.stringify(browser.params));
jasmine.getEnv().addReporter(new Reporter( browser.params )) ;
// Allow changing bootstrap mode to NG1 for upgrade tests
global.setProtractorToNg1Mode = function() {
browser.useAllAngular2AppRoots = false;
browser.rootEl = 'body';
};
},
jasmineNodeOpts: {
// defaultTimeoutInterval: 60000,
defaultTimeoutInterval: 10000,
showTiming: true,
print: function() {}
}
};
// Custom reporter
function Reporter(options) {
var _defaultOutputFile = path.resolve(process.cwd(), './_test-output', 'protractor-results.txt');
options.outputFile = options.outputFile || _defaultOutputFile;
initOutputFile(options.outputFile);
options.appDir = options.appDir || './';
var _root = { appDir: options.appDir, suites: [] };
log('AppDir: ' + options.appDir, +1);
var _currentSuite;
this.suiteStarted = function(suite) {
_currentSuite = { description: suite.description, status: null, specs: [] };
_root.suites.push(_currentSuite);
log('Suite: ' + suite.description, +1);
};
this.suiteDone = function(suite) {
var statuses = _currentSuite.specs.map(function(spec) {
return spec.status;
});
statuses = _.uniq(statuses);
var status = statuses.indexOf('failed') >= 0 ? 'failed' : statuses.join(', ');
_currentSuite.status = status;
log('Suite ' + _currentSuite.status + ': ' + suite.description, -1);
};
this.specStarted = function(spec) {
};
this.specDone = function(spec) {
var currentSpec = {
description: spec.description,
status: spec.status
};
if (spec.failedExpectations.length > 0) {
currentSpec.failedExpectations = spec.failedExpectations;
}
_currentSuite.specs.push(currentSpec);
log(spec.status + ' - ' + spec.description);
};
this.jasmineDone = function() {
outputFile = options.outputFile;
//// Alternate approach - just stringify the _root - not as pretty
//// but might be more useful for automation.
// var output = JSON.stringify(_root, null, 2);
var output = formatOutput(_root);
fs.appendFileSync(outputFile, output);
};
function ensureDirectoryExistence(filePath) {
var dirname = path.dirname(filePath);
if (directoryExists(dirname)) {
return true;
}
ensureDirectoryExistence(dirname);
fs.mkdirSync(dirname);
}
function directoryExists(path) {
try {
return fs.statSync(path).isDirectory();
}
catch (err) {
return false;
}
}
function initOutputFile(outputFile) {
ensureDirectoryExistence(outputFile);
var header = "Protractor results for: " + (new Date()).toLocaleString() + "\n\n";
fs.writeFileSync(outputFile, header);
}
// for output file output
function formatOutput(output) {
var indent = ' ';
var pad = ' ';
var results = [];
results.push('AppDir:' + output.appDir);
output.suites.forEach(function(suite) {
results.push(pad + 'Suite: ' + suite.description + ' -- ' + suite.status);
pad+=indent;
suite.specs.forEach(function(spec) {
results.push(pad + spec.status + ' - ' + spec.description);
if (spec.failedExpectations) {
pad+=indent;
spec.failedExpectations.forEach(function (fe) {
results.push(pad + 'message: ' + fe.message);
});
pad=pad.substr(2);
}
});
pad = pad.substr(2);
results.push('');
});
results.push('');
return results.join('\n');
}
// for console output
var _pad;
function log(str, indent) {
_pad = _pad || '';
if (indent == -1) {
_pad = _pad.substr(2);
}
console.log(_pad + str);
if (indent == 1) {
_pad = _pad + ' ';
}
}
}
h1 { /* Move down content because we have a fixed navbar that is 50px tall */
color: #369; body {
font-family: Arial, Helvetica, sans-serif; padding-top: 2rem;
font-size: 250%;
} }
/**
* Add barrels and stuff
* Adjust as necessary for your application needs.
*/
// (function (global) {
// System.config({
// packages: {
// // add packages here
// }
// });
// })(this);
...@@ -25,7 +25,11 @@ ...@@ -25,7 +25,11 @@
// other libraries // other libraries
'rxjs': 'npm:rxjs', 'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js' 'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
'jquery': 'npm:jquery/dist/jquery.min.js',
'tether': 'npm:tether/dist/js/tether.min.js',
'bootstrap': 'npm:bootstrap/dist/js/bootstrap.min.js'
}, },
// packages tells the System loader how to load when no filename and/or no extension // packages tells the System loader how to load when no filename and/or no extension
packages: { packages: {
......
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "es6",
"module": "commonjs", "module": "commonjs",
"moduleResolution": "node", "moduleResolution": "node",
"sourceMap": true, "sourceMap": true,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"lib": [ "es2015", "dom" ], "lib": [ "es2017", "dom" ],
"noImplicitAny": true, "noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true "suppressImplicitAnyIndexErrors": true
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment