Skip to content

Commit

Permalink
feat(log): add test script that will output logs
Browse files Browse the repository at this point in the history
  • Loading branch information
uittorio committed Jun 29, 2019
1 parent d247f8b commit d577cf8
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 26 deletions.
5 changes: 4 additions & 1 deletion config/karma/karma.config.base.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
const webpackConfig = require('../test/webpack.js');
const ProcessService = require('../process/process');
process.env.CHROME_BIN = require('puppeteer').executablePath();

module.exports = function(config, url) {
const debug = ProcessService(process).getArgument('DEBUG');

return {
basePath: '',
frameworks: ['jasmine'],
webpack: webpackConfig,
webpack: webpackConfig(debug),
webpackMiddleware: {
stats: 'errors-only'
},
Expand Down
18 changes: 18 additions & 0 deletions config/process/process.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function ProcessService(process) {
const processArguments = process.argv;

return {
getArgument(argumentName) {
let valueToFind = '';
processArguments.forEach((argument) => {
const values = argument.split('=');
if (argumentName === values[0])
valueToFind = values[1];
});

return valueToFind;
}
}
}

module.exports = ProcessService;
53 changes: 28 additions & 25 deletions config/test/webpack.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
const transformer = require('../../dist/transformer');
const path = require('path');
const webpack = require('webpack');

module.exports = {
mode: "development",
resolve: {
module.exports = function(debug) {
return {
mode: "development",
resolve: {
extensions: ['.ts', '.js'],
alias: {
['ts-auto-mock']: path.join(__dirname, '../../dist'),
['ts-auto-mock/repository']: path.join(__dirname, '../../dist/repository'),
['ts-auto-mock/extension']: path.join(__dirname, '../../dist/extension'),
alias: {
['ts-auto-mock']: path.join(__dirname, '../../dist'),
['ts-auto-mock/repository']: path.join(__dirname, '../../dist/repository'),
['ts-auto-mock/extension']: path.join(__dirname, '../../dist/extension'),
}
},
module: {
rules: [
{
test: /\.ts$/,
enforce: 'pre',
loader: 'tslint-loader'
},
{
test: /\.ts$/,
loader: 'awesome-typescript-loader',
options: {
configFileName: "test/tsconfig.json",
getCustomTransformers: (program) => ({
before: [ transformer.default(program) ]
})
module: {
rules: [
{
test: /\.ts$/,
enforce: 'pre',
loader: 'tslint-loader'
},
{
test: /\.ts$/,
loader: 'awesome-typescript-loader',
options: {
configFileName: "test/tsconfig.json",
getCustomTransformers: (program) => ({
before: [ transformer.default(program, {
debug: debug ? 'file' : false
}) ]
})
}
}
}
]
]
}
}
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"build:extension": "webpack --config config/modules/extension/webpack.js",
"build": "npm run build:mock && npm run build:transformer && npm run build:repository && npm run build:extension",
"test": "npm run test:transformer && npm run test:framework",
"test:debug": "npm run test:transformer DEBUG=true && npm run test:framework DEBUG=true",
"test:transformer": "karma start config/karma/karma.config.transformer.js",
"test:framework": "karma start config/karma/karma.config.framework.js",
"version": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md",
Expand Down

0 comments on commit d577cf8

Please sign in to comment.