From 037372dfbacb2b97ee8a7dcad25bb7c7443b9fb6 Mon Sep 17 00:00:00 2001 From: Andrea Balducci Date: Thu, 4 Oct 2018 20:16:12 +0200 Subject: [PATCH 1/2] added wallaby.js --- package.json | 4 ++- src/wallabyTest.ts | 14 ++++++++ tsconfig.json | 7 +++- wallaby.js | 83 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 src/wallabyTest.ts create mode 100644 wallaby.js diff --git a/package.json b/package.json index 8cb123c..1be65dc 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "@types/jasmine": "2.8.8", "@types/jasminewd2": "2.0.3", "@types/node": "10.11.2", + "angular2-template-loader": "^0.6.2", "codelyzer": "4.4.4", "jasmine-core": "3.2.1", "jasmine-marbles": "0.4.0", @@ -50,6 +51,7 @@ "protractor": "5.4.1", "ts-node": "7.0.1", "tslint": "5.11.0", - "typescript": "2.9.2" + "typescript": "2.9.2", + "wallaby-webpack": "^3.9.12" } } diff --git a/src/wallabyTest.ts b/src/wallabyTest.ts new file mode 100644 index 0000000..a0a2899 --- /dev/null +++ b/src/wallabyTest.ts @@ -0,0 +1,14 @@ +import './polyfills'; + +import 'zone.js/dist/zone-testing'; + +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; + +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting() +); diff --git a/tsconfig.json b/tsconfig.json index ef44e28..3127778 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,5 +16,10 @@ "es2017", "dom" ] - } + }, + "exclude": [ + "test.ts", + "wallabyTest.ts", + "**/*.spec.ts" + ] } diff --git a/wallaby.js b/wallaby.js new file mode 100644 index 0000000..046e1a2 --- /dev/null +++ b/wallaby.js @@ -0,0 +1,83 @@ +var wallabyWebpack = require('wallaby-webpack'); +var path = require('path'); + +var compilerOptions = Object.assign( + require('./tsconfig.json').compilerOptions, + require('./src/tsconfig.spec.json').compilerOptions); + +compilerOptions.module = 'CommonJs'; + +module.exports = function (wallaby) { + + var webpackPostprocessor = wallabyWebpack({ + entryPatterns: [ + 'src/wallabyTest.js', + 'src/**/*spec.js' + ], + + module: { + rules: [ + {test: /\.css$/, loader: ['raw-loader']}, + {test: /\.html$/, loader: 'raw-loader'}, + {test: /\.ts$/, loader: '@ngtools/webpack', include: /node_modules/, query: {tsConfigPath: 'tsconfig.json'}}, + {test: /\.js$/, loader: 'angular2-template-loader', exclude: /node_modules/}, + {test: /\.styl$/, loaders: ['raw-loader', 'stylus-loader']}, + {test: /\.less$/, loaders: ['raw-loader', {loader: 'less-loader', options: {paths: [__dirname]}}]}, + {test: /\.scss$|\.sass$/, loaders: ['raw-loader', 'sass-loader']}, + {test: /\.(jpg|png|svg)$/, loader: 'url-loader?limit=128000'} + ] + }, + + resolve: { + extensions: ['.js', '.ts'], + modules: [ + path.join(wallaby.projectCacheDir, 'src/app'), + path.join(wallaby.projectCacheDir, 'src'), + 'node_modules' + ] + }, + node: { + fs: 'empty', + net: 'empty', + tls: 'empty', + dns: 'empty' + } + }); + + return { + files: [ + {pattern: 'src/**/*.+(ts|css|less|scss|sass|styl|html|json|svg)', load: false}, + {pattern: 'src/**/*.d.ts', ignore: true}, + {pattern: 'src/**/*spec.ts', ignore: true} + ], + + tests: [ + {pattern: 'src/**/*spec.ts', load: false}, + {pattern: 'src/**/*e2e-spec.ts', ignore: true} + ], + + testFramework: 'jasmine', + + compilers: { + '**/*.ts': wallaby.compilers.typeScript(compilerOptions) + }, + + middleware: function (app, express) { + var path = require('path'); + app.use('/favicon.ico', express.static(path.join(__dirname, 'src/favicon.ico'))); + app.use('/assets', express.static(path.join(__dirname, 'src/assets'))); + }, + + env: { + kind: 'chrome' + }, + + postprocessor: webpackPostprocessor, + + setup: function () { + window.__moduleBundler.loadTests(); + }, + + debug: true + }; +}; \ No newline at end of file From 0e3ff5bd387ab2a485cf9c865036fcc761969007 Mon Sep 17 00:00:00 2001 From: Andrea Balducci Date: Thu, 4 Oct 2018 20:20:41 +0200 Subject: [PATCH 2/2] fixed tsconfig.json --- tsconfig.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 3127778..75ded38 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,8 +18,6 @@ ] }, "exclude": [ - "test.ts", - "wallabyTest.ts", - "**/*.spec.ts" + "wallabyTest.ts" ] }