Added a first simple test.
That serves as a proof-of-concept and as a template for future tests. It's a start!
This commit is contained in:
parent
f3b5a7580a
commit
77a79bf588
7 changed files with 139 additions and 2 deletions
|
@ -9,6 +9,7 @@ build_job:
|
||||||
script:
|
script:
|
||||||
- npm install
|
- npm install
|
||||||
- npm run build
|
- npm run build
|
||||||
|
- npm run test
|
||||||
tags:
|
tags:
|
||||||
- javascript
|
- javascript
|
||||||
except:
|
except:
|
||||||
|
|
21
config/karma-test-shim.js
Normal file
21
config/karma-test-shim.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
Error.stackTraceLimit = Infinity;
|
||||||
|
|
||||||
|
require('core-js/es6');
|
||||||
|
require('core-js/es7/reflect');
|
||||||
|
|
||||||
|
require('zone.js/dist/zone');
|
||||||
|
require('zone.js/dist/long-stack-trace-zone');
|
||||||
|
require('zone.js/dist/proxy');
|
||||||
|
require('zone.js/dist/sync-test');
|
||||||
|
require('zone.js/dist/jasmine-patch');
|
||||||
|
require('zone.js/dist/async-test');
|
||||||
|
require('zone.js/dist/fake-async-test');
|
||||||
|
|
||||||
|
var appContext = require.context('../src', true, /\.spec\.ts/);
|
||||||
|
|
||||||
|
appContext.keys().forEach(appContext);
|
||||||
|
|
||||||
|
var testing = require('@angular/core/testing');
|
||||||
|
var browser = require('@angular/platform-browser-dynamic/testing');
|
||||||
|
|
||||||
|
testing.TestBed.initTestEnvironment(browser.BrowserDynamicTestingModule, browser.platformBrowserDynamicTesting());
|
44
config/karma.conf.js
Normal file
44
config/karma.conf.js
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
var webpackConfig = require('./webpack.test');
|
||||||
|
|
||||||
|
module.exports = function (config) {
|
||||||
|
var _config = {
|
||||||
|
basePath: '',
|
||||||
|
|
||||||
|
frameworks: ['jasmine'],
|
||||||
|
|
||||||
|
files: [
|
||||||
|
{
|
||||||
|
pattern: './config/karma-test-shim.js',
|
||||||
|
watched: false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
preprocessors: {
|
||||||
|
'./config/karma-test-shim.js': ['webpack', 'sourcemap']
|
||||||
|
},
|
||||||
|
|
||||||
|
webpack: webpackConfig,
|
||||||
|
|
||||||
|
webpackMiddleware: {
|
||||||
|
stats: 'errors-only'
|
||||||
|
},
|
||||||
|
|
||||||
|
webpackServer: {
|
||||||
|
noInfo: true
|
||||||
|
},
|
||||||
|
|
||||||
|
reporters: ['kjhtml'],
|
||||||
|
port: 9876,
|
||||||
|
colors: true,
|
||||||
|
logLevel: config.LOG_INFO,
|
||||||
|
autoWatch: false,
|
||||||
|
browsers: ['PhantomJS'],
|
||||||
|
singleRun: true,
|
||||||
|
phantomjsLauncher: {
|
||||||
|
// Have phantomjs exit if a ResourceError is encountered (useful if karma exits without killing phantom)
|
||||||
|
exitOnResourceError: true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
config.set(_config);
|
||||||
|
};
|
52
config/webpack.test.js
Normal file
52
config/webpack.test.js
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
var webpack = require('webpack');
|
||||||
|
var helpers = require('./helpers');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
devtool: 'inline-source-map',
|
||||||
|
|
||||||
|
resolve: {
|
||||||
|
extensions: ['.ts', '.js']
|
||||||
|
},
|
||||||
|
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.ts$/,
|
||||||
|
loaders: [
|
||||||
|
{
|
||||||
|
loader: 'awesome-typescript-loader',
|
||||||
|
options: {configFileName: helpers.root('src', 'tsconfig.json')}
|
||||||
|
}, 'angular2-template-loader'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.html$/,
|
||||||
|
loader: 'html-loader'
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
|
||||||
|
loader: 'null-loader'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.css$/,
|
||||||
|
exclude: helpers.root('src', 'app'),
|
||||||
|
loader: 'null-loader'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.css$/,
|
||||||
|
include: helpers.root('src', 'app'),
|
||||||
|
loader: 'raw-loader'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
plugins: [
|
||||||
|
new webpack.ContextReplacementPlugin(
|
||||||
|
// The (\\|\/) piece accounts for path separators in *nix and Windows
|
||||||
|
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
|
||||||
|
helpers.root('./src'), // location of your src
|
||||||
|
{} // a map of your routes
|
||||||
|
)
|
||||||
|
]
|
||||||
|
};
|
|
@ -35,8 +35,8 @@
|
||||||
"punycode": "^1.4.0"
|
"punycode": "^1.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^6.0.45",
|
|
||||||
"@types/jasmine": "2.5.36",
|
"@types/jasmine": "2.5.36",
|
||||||
|
"@types/node": "^6.0.45",
|
||||||
"angular2-template-loader": "^0.6.0",
|
"angular2-template-loader": "^0.6.0",
|
||||||
"awesome-typescript-loader": "^3.0.4",
|
"awesome-typescript-loader": "^3.0.4",
|
||||||
"css-loader": "^0.26.1",
|
"css-loader": "^0.26.1",
|
||||||
|
@ -47,10 +47,14 @@
|
||||||
"jasmine-core": "^2.4.1",
|
"jasmine-core": "^2.4.1",
|
||||||
"karma": "^1.2.0",
|
"karma": "^1.2.0",
|
||||||
"karma-chrome-launcher": "^2.0.0",
|
"karma-chrome-launcher": "^2.0.0",
|
||||||
|
"karma-firefox-launcher": "^1.0.1",
|
||||||
"karma-jasmine": "^1.0.2",
|
"karma-jasmine": "^1.0.2",
|
||||||
|
"karma-jasmine-html-reporter": "^0.2.2",
|
||||||
|
"karma-phantomjs-launcher": "^1.0.4",
|
||||||
"karma-sourcemap-loader": "^0.3.7",
|
"karma-sourcemap-loader": "^0.3.7",
|
||||||
"karma-webpack": "^2.0.1",
|
"karma-webpack": "^2.0.1",
|
||||||
"null-loader": "^0.1.1",
|
"null-loader": "^0.1.1",
|
||||||
|
"phantomjs-prebuilt": "^2.1.14",
|
||||||
"raw-loader": "^0.5.1",
|
"raw-loader": "^0.5.1",
|
||||||
"rimraf": "^2.5.2",
|
"rimraf": "^2.5.2",
|
||||||
"style-loader": "^0.13.1",
|
"style-loader": "^0.13.1",
|
||||||
|
|
16
src/app/app.component.spec.ts
Normal file
16
src/app/app.component.spec.ts
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import {TestBed} from "@angular/core/testing";
|
||||||
|
import {AppComponent} from "./app.component";
|
||||||
|
import {FormsModule} from "@angular/forms";
|
||||||
|
|
||||||
|
describe('App', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [AppComponent],
|
||||||
|
imports: [FormsModule]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('should work', () => {
|
||||||
|
let fixture = TestBed.createComponent(AppComponent);
|
||||||
|
expect(fixture.componentInstance instanceof AppComponent).toBe(true, 'should create AppComponent');
|
||||||
|
});
|
||||||
|
});
|
|
@ -4,7 +4,6 @@ import {InputComponentManagerService} from "./inputcomponentmanager.service";
|
||||||
import {Converter} from "./converter/converter";
|
import {Converter} from "./converter/converter";
|
||||||
import {NativeLibraryWrapperService} from "./nativelibrarywrapper.service";
|
import {NativeLibraryWrapperService} from "./nativelibrarywrapper.service";
|
||||||
import {Step} from "./step";
|
import {Step} from "./step";
|
||||||
|
|
||||||
import "../assets/css/style.css";
|
import "../assets/css/style.css";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
Loading…
Reference in a new issue