Commit 3c279d5b authored by dev0tion's avatar dev0tion

Fix Karma Tests

parent a9236b50
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
"main": "main.ts", "main": "main.ts",
"polyfills": "polyfills.ts", "polyfills": "polyfills.ts",
"test": "test.ts", "test": "test.ts",
"tsconfig": "tsconfig.json", "tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.json", "testTsconfig": "tsconfig.spec.json",
"prefix": "app", "prefix": "app",
"styles": [ "styles": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css", "../node_modules/bootstrap/dist/css/bootstrap.min.css",
...@@ -36,12 +36,13 @@ ...@@ -36,12 +36,13 @@
}, },
"lint": [ "lint": [
{ {
"files": "src/**/*.ts", "project": "src/tsconfig.app.json"
"project": "src/tsconfig.json"
}, },
{ {
"files": "e2e/**/*.ts", "project": "src/tsconfig.spec.json"
"project": "e2e/tsconfig.json" },
{
"project": "e2e/tsconfig.e2e.json"
} }
], ],
"test": { "test": {
......
...@@ -4,40 +4,43 @@ ...@@ -4,40 +4,43 @@
module.exports = function (config) { module.exports = function (config) {
config.set({ config.set({
basePath: '', basePath: '',
frameworks: ['jasmine', 'angular-cli'], frameworks: ['jasmine', '@angular/cli'],
plugins: [ plugins: [
require('karma-jasmine'), require('karma-jasmine'),
require('karma-chrome-launcher'), require('karma-electron'),
require('karma-remap-istanbul'), require('karma-jasmine-html-reporter'),
require('angular-cli/plugins/karma') require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma')
], ],
client:{
useIframe: false,
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
files: [ files: [
{ pattern: './src/test.ts', watched: false } { pattern: './src/test.ts', watched: false }
], ],
preprocessors: { preprocessors: {
'./src/test.ts': ['angular-cli'] './src/test.ts': ['@angular/cli']
}, },
mime: { mime: {
'text/x-typescript': ['ts','tsx'] 'text/x-typescript': ['ts','tsx']
}, },
remapIstanbulReporter: { coverageIstanbulReporter: {
reports: { reports: [ 'html', 'lcovonly' ],
html: 'coverage', fixWebpackSourcePaths: true
lcovonly: './coverage/coverage.lcov'
}
}, },
angularCli: { angularCli: {
config: './angular-cli.json', config: './angular-cli.json',
environment: 'dev' environment: 'dev'
}, },
reporters: config.angularCli && config.angularCli.codeCoverage reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'karma-remap-istanbul'] ? ['progress', 'coverage-istanbul']
: ['progress'], : ['progress', 'kjhtml'],
port: 9876, port: 9876,
colors: true, colors: true,
logLevel: config.LOG_INFO, logLevel: config.LOG_INFO,
autoWatch: true, autoWatch: true,
browsers: ['Chrome'], browsers: ['Electron'],
singleRun: false singleRun: false
}); });
}; };
...@@ -44,41 +44,45 @@ ...@@ -44,41 +44,45 @@
"@types/electron": "^1.4.35", "@types/electron": "^1.4.35",
"@types/jasmine": "2.5.46", "@types/jasmine": "2.5.46",
"@types/node": "~7.0.12", "@types/node": "~7.0.12",
"autoprefixer": "^6.5.3",
"codelyzer": "~2.0.0", "codelyzer": "~2.0.0",
"concurrently": "^3.4.0", "concurrently": "^3.4.0",
"copy-webpack-plugin": "^4.0.1", "copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.26.1",
"cssnano": "^3.10.0",
"electron": "^1.6.2", "electron": "^1.6.2",
"electron-packager": "^8.6.0", "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-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0", "jasmine-spec-reporter": "~3.2.0",
"json-loader": "^0.5.4",
"karma": "~1.5.0", "karma": "~1.5.0",
"karma-chrome-launcher": "~2.0.0", "karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1", "karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.0.0", "karma-coverage-istanbul-reporter": "^1.0.0",
"karma-electron": "^5.1.1",
"karma-jasmine": "~1.1.0", "karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2", "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", "karma-sourcemap-loader": "^0.3.7",
"less-loader": "^2.2.3", "less-loader": "^2.2.3",
"postcss-loader": "^0.13.0", "postcss-loader": "^0.13.0",
"postcss-url": "^5.1.2", "postcss-url": "^5.1.2",
"protractor": "~5.1.1",
"raw-loader": "^0.5.1", "raw-loader": "^0.5.1",
"sass-loader": "^4.1.1", "sass-loader": "^4.1.1",
"script-loader": "^0.7.0", "script-loader": "^0.7.0",
"source-map-loader": "^0.1.5", "source-map-loader": "^0.1.5",
"istanbul-instrumenter-loader": "^2.0.0",
"style-loader": "^0.13.1", "style-loader": "^0.13.1",
"stylus-loader": "^2.4.0", "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"
} }
} }
...@@ -10,6 +10,10 @@ exports.config = { ...@@ -10,6 +10,10 @@ exports.config = {
'./e2e/**/*.e2e-spec.ts' './e2e/**/*.e2e-spec.ts'
], ],
capabilities: { capabilities: {
chromeOptions: {
binary: './node_modules/electron/dist/electron',
args: ['--test-type=webdriver']
},
'browserName': 'chrome' 'browserName': 'chrome'
}, },
directConnect: true, directConnect: true,
...@@ -23,7 +27,7 @@ exports.config = { ...@@ -23,7 +27,7 @@ exports.config = {
useAllAngular2AppRoots: true, useAllAngular2AppRoots: true,
beforeLaunch: function() { beforeLaunch: function() {
require('ts-node').register({ require('ts-node').register({
project: 'e2e' project: 'e2e/tsconfig.e2e.json'
}); });
}, },
onPrepare: function() { onPrepare: function() {
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { TestBed, async } from '@angular/core/testing'; import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { RouterTestingModule } from '@angular/router/testing';
describe('AppComponent', () => { describe('AppComponent', () => {
beforeEach(() => { beforeEach(() => {
...@@ -9,6 +10,9 @@ describe('AppComponent', () => { ...@@ -9,6 +10,9 @@ describe('AppComponent', () => {
declarations: [ declarations: [
AppComponent AppComponent
], ],
imports: [
RouterTestingModule
]
}); });
TestBed.compileComponents(); TestBed.compileComponents();
}); });
...@@ -18,17 +22,4 @@ describe('AppComponent', () => { ...@@ -18,17 +22,4 @@ describe('AppComponent', () => {
const app = fixture.debugElement.componentInstance; const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy(); 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 = { ...@@ -198,10 +198,6 @@ module.exports = {
}, },
"plugins": [ "plugins": [
new NoEmitOnErrorsPlugin(), new NoEmitOnErrorsPlugin(),
new CopyWebpackPlugin([{
context: path.resolve(__dirname, "src"),
from: "electron.js"
}]),
new GlobCopyWebpackPlugin({ new GlobCopyWebpackPlugin({
"patterns": [ "patterns": [
"assets" "assets"
...@@ -212,6 +208,10 @@ module.exports = { ...@@ -212,6 +208,10 @@ module.exports = {
"ignore": "**/.gitkeep" "ignore": "**/.gitkeep"
} }
}), }),
new CopyWebpackPlugin([{
context: path.resolve(__dirname, "src"),
from: "electron.js"
}]),
new ProgressPlugin(), new ProgressPlugin(),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
"template": "./src/index.html", "template": "./src/index.html",
...@@ -299,7 +299,7 @@ module.exports = { ...@@ -299,7 +299,7 @@ module.exports = {
"environments/environment.ts": "environments/environment.ts" "environments/environment.ts": "environments/environment.ts"
}, },
"exclude": [], "exclude": [],
"tsConfigPath": "src/tsconfig.json", "tsConfigPath": "src/tsconfig.app.json",
"skipCodeGeneration": true "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