Skip to content

Commit

Permalink
testing framework
Browse files Browse the repository at this point in the history
  • Loading branch information
davidf committed Mar 28, 2018
1 parent 1e20e05 commit 4fac9ec
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 6 deletions.
12 changes: 7 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ node_modules/*
src/node_modules/*
npm-debug.log

package-lock.json

# TypeScript
src/*.js
src/*.map
src/*.d.ts
src/*metadata.json
src/*summary.json
src/**/*.js
src/**/*.map
src/**/*.d.ts
src/**/*metadata.json
src/**/*summary.json

# JetBrains

Expand Down
16 changes: 16 additions & 0 deletions init-test-bed.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'reflect-metadata';
import 'zone.js/dist/zone.js';
import 'zone.js/dist/proxy.js';
import 'zone.js/dist/sync-test.js';
import 'zone.js/dist/jasmine-patch.js';
import 'zone.js/dist/async-test.js';
import {TestBed} from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';

TestBed.initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
91 changes: 91 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Karma configuration
// Generated on Mon Jul 17 2017 09:12:56 GMT-0500 (CDT)

module.exports = function (config) {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '.',


// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine', 'karma-typescript'],


// list of files / patterns to load in the browser
files: [
'init-test-bed.spec.ts',
'src/**/*.ts',
{pattern: 'src/**/*.html', included: false, watched: true}
],


// list of files to exclude
exclude: [],


// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'**/*.ts': ['karma-typescript']
},

karmaTypescriptConfig: {
bundlerOptions: {
entrypoints: /\.spec\.ts$/,
transforms: [
require("karma-typescript-es6-transform")(),
// require('karma-typescript-angular2-transform'),
]

},
compilerOptions: {
lib: ['ES2015', 'DOM']
}
},
customLaunchers: {
Chrome_with_debugging: {
base: 'Chrome',
flags: ['--remote-debugging-port=9222'],
debug: true
}
},
browserNoActivityTimeout: 300000, // default 10000
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress', 'kjhtml'],


// web server port
port: 9876,


// enable / disable colors in the output (reporters and logs)
colors: true,


// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,


// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,


// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],


// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity,
})
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-typescript": "^3.0.12",
"karma-typescript-es6-transform": "^1.0.4",
"node-sass": "^4.5.2",
"node-sass-tilde-importer": "^1.0.0",
"node-watch": "^0.5.2",
Expand Down
9 changes: 8 additions & 1 deletion src/logger.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
import { TestBed, async, inject } from '@angular/core/testing';
import { NGXLogger } from './logger.service';
import {} from 'jasmine';
import {NGXLoggerHttpService} from './http.service';
import {NGXLoggerHttpServiceMock} from './http.service.mock';
import {LoggerConfig} from './logger.config';

describe('NGXLogger', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [NGXLogger]
providers: [
NGXLogger,
{provide: NGXLoggerHttpService, useClass: NGXLoggerHttpServiceMock},
LoggerConfig
]
});
});

Expand Down

0 comments on commit 4fac9ec

Please sign in to comment.