Commit f6473308 authored by Pieterjan Vanhoof's avatar Pieterjan Vanhoof Committed by GitHub

Merge pull request #11 from stratisproject/ui

Fix tests
- Fixed Unit (Karma) tests
- Fixed End2End (Protractor) tests
parents 739aa7fe 7174b285
......@@ -14,8 +14,8 @@
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"testTsconfig": "tsconfig.json",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
......@@ -36,12 +36,13 @@
},
"lint": [
{
"files": "src/**/*.ts",
"project": "src/tsconfig.json"
"project": "src/tsconfig.app.json"
},
{
"files": "e2e/**/*.ts",
"project": "e2e/tsconfig.json"
"project": "src/tsconfig.spec.json"
},
{
"project": "e2e/tsconfig.e2e.json"
}
],
"test": {
......
import { BreezeUIPage } from './app.po';
import { BreezePage } from './app.po';
describe('breeze-ui App', function() {
let page: BreezeUIPage;
describe('breeze App', function() {
let page: BreezePage;
beforeEach(() => {
page = new BreezeUIPage();
page = new BreezePage();
});
it('should display message saying app works', () => {
it('title should be Breeze', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('app works!');
expect(page.getTitle()).toEqual('Breeze');
});
});
import { browser, element, by } from 'protractor';
export class BreezeUIPage {
export class BreezePage {
navigateTo() {
return browser.get('/');
}
getParagraphText() {
return element(by.css('app-root h1')).getText();
}
getTitle() {
let title: string;
return browser.getTitle();
}
}
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/e2e",
"module": "commonjs",
"target": "es5",
"typeRoots": [
"../node_modules/@types"
],
"types":[
"jasmine",
"node"
]
}
}
\ No newline at end of file
{
"compileOnSave": false,
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"module": "commonjs",
"moduleResolution": "node",
"outDir": "../dist/out-tsc-e2e",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types"
]
}
}
......@@ -4,40 +4,43 @@
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', 'angular-cli'],
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-remap-istanbul'),
require('angular-cli/plugins/karma')
require('karma-electron'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma')
],
client:{
useIframe: false,
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
files: [
{ pattern: './src/test.ts', watched: false }
],
preprocessors: {
'./src/test.ts': ['angular-cli']
'./src/test.ts': ['@angular/cli']
},
mime: {
'text/x-typescript': ['ts','tsx']
},
remapIstanbulReporter: {
reports: {
html: 'coverage',
lcovonly: './coverage/coverage.lcov'
}
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},
angularCli: {
config: './angular-cli.json',
environment: 'dev'
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'karma-remap-istanbul']
: ['progress'],
? ['progress', 'coverage-istanbul']
: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
browsers: ['Electron'],
singleRun: false
});
};
......@@ -44,41 +44,45 @@
"@types/electron": "^1.4.35",
"@types/jasmine": "2.5.46",
"@types/node": "~7.0.12",
"autoprefixer": "^6.5.3",
"codelyzer": "~2.0.0",
"concurrently": "^3.4.0",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.26.1",
"cssnano": "^3.10.0",
"electron": "^1.6.2",
"electron-packager": "^8.6.0",
"exports-loader": "^0.6.3",
"extract-text-webpack-plugin": "^2.1.0",
"file-loader": "^0.10.0",
"html-webpack-plugin": "^2.28.0",
"istanbul-instrumenter-loader": "^2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"json-loader": "^0.5.4",
"karma": "~1.5.0",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.0.0",
"karma-electron": "^5.1.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.1",
"ts-node": "~3.0.2",
"tslint": "~4.5.1",
"typescript": "^2.2.2",
"webpack-dev-server": "~2.3.0",
"autoprefixer": "^6.5.3",
"css-loader": "^0.26.1",
"cssnano": "^3.10.0",
"exports-loader": "^0.6.3",
"file-loader": "^0.10.0",
"json-loader": "^0.5.4",
"karma-sourcemap-loader": "^0.3.7",
"less-loader": "^2.2.3",
"postcss-loader": "^0.13.0",
"postcss-url": "^5.1.2",
"protractor": "~5.1.1",
"raw-loader": "^0.5.1",
"sass-loader": "^4.1.1",
"script-loader": "^0.7.0",
"source-map-loader": "^0.1.5",
"istanbul-instrumenter-loader": "^2.0.0",
"style-loader": "^0.13.1",
"stylus-loader": "^2.4.0",
"url-loader": "^0.5.7"
"ts-node": "~3.0.2",
"tslint": "~4.5.1",
"typescript": "^2.2.2",
"url-loader": "^0.5.7",
"webpack": "^2.3.2",
"webpack-dev-server": "~2.3.0"
}
}
......@@ -2,7 +2,8 @@
// https://github.com/angular/protractor/blob/master/lib/config.ts
/*global jasmine */
var SpecReporter = require('jasmine-spec-reporter');
// let SpecReporter = require('jasmine-spec-reporter').SpecReporter;
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
......@@ -10,6 +11,10 @@ exports.config = {
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
chromeOptions: {
binary: './node_modules/electron/dist/electron',
args: ['--test-type=webdriver']
},
'browserName': 'chrome'
},
directConnect: true,
......@@ -23,7 +28,7 @@ exports.config = {
useAllAngular2AppRoots: true,
beforeLaunch: function() {
require('ts-node').register({
project: 'e2e'
project: 'e2e/tsconfig.e2e.json'
});
},
onPrepare: function() {
......
......@@ -2,6 +2,7 @@
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { RouterTestingModule } from '@angular/router/testing';
describe('AppComponent', () => {
beforeEach(() => {
......@@ -9,6 +10,9 @@ describe('AppComponent', () => {
declarations: [
AppComponent
],
imports: [
RouterTestingModule
]
});
TestBed.compileComponents();
});
......@@ -18,17 +22,4 @@ describe('AppComponent', () => {
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
it(`should have as title 'app works!'`, async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app works!');
}));
it('should render title in a h1 tag', async(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('app works!');
}));
});
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"baseUrl": "",
"typeRoots": [
"../node_modules/@types"
],
"types": [
"node"
]
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}
\ No newline at end of file
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"module": "commonjs",
"target": "es5",
"baseUrl": "",
"typeRoots": [
"../node_modules/@types"
],
"types": [
"jasmine",
"node"
]
},
"files": [
"test.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}
......@@ -198,10 +198,6 @@ module.exports = {
},
"plugins": [
new NoEmitOnErrorsPlugin(),
new CopyWebpackPlugin([{
context: path.resolve(__dirname, "src"),
from: "electron.js"
}]),
new GlobCopyWebpackPlugin({
"patterns": [
"assets"
......@@ -212,6 +208,10 @@ module.exports = {
"ignore": "**/.gitkeep"
}
}),
new CopyWebpackPlugin([{
context: path.resolve(__dirname, "src"),
from: "electron.js"
}]),
new ProgressPlugin(),
new HtmlWebpackPlugin({
"template": "./src/index.html",
......@@ -299,7 +299,7 @@ module.exports = {
"environments/environment.ts": "environments/environment.ts"
},
"exclude": [],
"tsConfigPath": "src/tsconfig.json",
"tsConfigPath": "src/tsconfig.app.json",
"skipCodeGeneration": 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