Skip to content

Commit 2cd3552

Browse files
authored
Merge pull request #98 from marc101101/feature/create-test-concept
Feature/create test concept
2 parents b2eb104 + 177352b commit 2cd3552

8 files changed

Lines changed: 83 additions & 50 deletions

File tree

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ language: node_js
22
node_js:
33
- "9"
44

5+
sudo: required
6+
57
addons:
68
mariadb: "10.3"
9+
chrome: stable
710

811
before_install:
912
- mysql -e "CREATE DATABASE usr_p100480_1;"
1013
- mysql usr_p100480_1 < ./server/usr_p100480_1.sql
14+
- export CHROME_BIN=chromium-browser
15+
- export DISPLAY=:99.0
16+
- sh -e /etc/init.d/xvfb start
1117

1218
cache:
1319
yarn: true

angular.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"builder": "@angular-devkit/build-angular:karma",
7070
"options": {
7171
"main": "client/test.ts",
72-
"karmaConfig": "./karma.conf.js",
72+
"karmaConfig": "./client/karma.conf.js",
7373
"polyfills": "client/polyfills.ts",
7474
"tsConfig": "client/tsconfig.spec.json",
7575
"scripts": [],

client/app/services/auth.service.spec.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

client/app/services/auth.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { environment } from '../../environments/environement';
77
@Injectable({
88
providedIn: 'root'
99
})
10+
1011
export class AuthService {
1112

1213
private authStatus: boolean = false;

client/karma.conf.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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-devkit/build-angular'],
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-devkit/build-angular/plugins/karma'),
14+
require('karma-scss-preprocessor')
15+
],
16+
client: {
17+
clearContext: false // leave Jasmine Spec Runner output visible in browser
18+
},
19+
files: [{
20+
pattern: '../node_modules/@angular/material/prebuilt-themes/indigo-pink.css',
21+
included: true,
22+
watched: true
23+
},
24+
{
25+
pattern: './test.ts',
26+
watched: false
27+
},
28+
{
29+
pattern: './app/styles/**/*.*',
30+
watched: true,
31+
included: true,
32+
served: true
33+
}
34+
],
35+
preprocessors: {
36+
'./app/styles/**/*.*': ['scss']
37+
},
38+
coverageIstanbulReporter: {
39+
dir: require('path').join(__dirname, '../coverage'),
40+
reports: ['html', 'lcovonly'],
41+
fixWebpackSourcePaths: true
42+
},
43+
reporters: ['progress', 'kjhtml'],
44+
port: 9876,
45+
colors: true,
46+
logLevel: config.LOG_INFO,
47+
autoWatch: true,
48+
browsers: ['Chrome_travis_ci'],
49+
singleRun: true,
50+
customLaunchers: {
51+
Chrome_travis_ci: {
52+
base: 'Chrome',
53+
flags: ['--no-sandbox']
54+
}
55+
},
56+
});
57+
58+
if (process.env.TRAVIS) {
59+
config.browsers = ['Chrome_travis_ci'];
60+
}
61+
};

client/test.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
1-
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
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';
1+
import 'zone.js/dist/zone-testing';
92
import { getTestBed } from '@angular/core/testing';
103
import {
114
BrowserDynamicTestingModule,
125
platformBrowserDynamicTesting
136
} from '@angular/platform-browser-dynamic/testing';
147

15-
// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
16-
declare const __karma__: any;
178
declare const require: any;
189

19-
// Prevent Karma from running prematurely.
20-
__karma__.loaded = function () {};
21-
2210
// First, initialize the Angular testing environment.
2311
getTestBed().initTestEnvironment(
2412
BrowserDynamicTestingModule,
@@ -27,6 +15,4 @@ getTestBed().initTestEnvironment(
2715
// Then we find all the tests.
2816
const context = require.context('./', true, /\.spec\.ts$/);
2917
// And load the modules.
30-
context.keys().map(context);
31-
// Finally, start Karma to run the tests.
32-
__karma__.start();
18+
context.keys().map(context);

client/tsconfig.server.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

package.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"build:client": "ng build",
1111
"start:prod": "ng build --prod && npm run start:server",
1212
"test:server": "NODE_ENV=test mocha --exit ./server/test/*.js",
13-
"test:client": "echo 'frontend tests missing'",
13+
"test:client": "ng test",
1414
"test:server_local": "mysql.server start && NODE_ENV=test mocha --exit ./server/test/*.js && mysql.server stop",
1515
"test": "npm run test:server && npm run test:client",
1616
"lint": "ng lint",
@@ -79,6 +79,16 @@
7979
"protractor": "~5.1.2",
8080
"ts-node": "~3.2.0",
8181
"tslint": "~5.7.0",
82-
"typescript": "~2.7.2"
82+
"typescript": "~2.7.2",
83+
"jasmine-core": "3.1.0",
84+
"jasmine-spec-reporter": "4.2.1",
85+
"karma": "2.0.2",
86+
"karma-chrome-launcher": "2.2.0",
87+
"karma-cli": "1.0.1",
88+
"karma-coverage-istanbul-reporter": "1.4.2",
89+
"karma-jasmine": "1.1.2",
90+
"karma-jasmine-html-reporter": "1.0.0",
91+
"karma-remap-istanbul": "0.6.0",
92+
"karma-scss-preprocessor": "3.0.0"
8393
}
8494
}

0 commit comments

Comments
 (0)