Skip to content

Commit

Permalink
chore: add integration tests for migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 committed Apr 6, 2020
1 parent 70c7539 commit a3093bd
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/migrate/config/migrate-config.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

const { run } = require('../../utils/test-utils');

describe('migrate command', () => {
it('should warn if the source config file is not specified', () => {
const { stderr } = run(__dirname, ['migrate'], false);
expect(stderr).toContain('Please specify a path to your webpack config');
});

it('should prompt accordingly if an output path is not specified', () => {
const { stdout, stderr } = run(__dirname, ['migrate', 'webpack.config.js'], false);
expect(stdout).toContain('Migration output path not specified.');
expect(stderr).toBeFalsy();
});

it('should work fine', () => {
const { stdout, stderr } = run(__dirname, ['migrate', 'webpack.config.js', 'output.js'], false);
expect(stdout).toBeTruthy();
expect(stderr).toBeFalsy();
});
});
62 changes: 62 additions & 0 deletions test/migrate/config/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/* eslint-disable */
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const webpack = require('webpack');

module.exports = {
entry: {
index: './src/index.js',
vendor: './src/vendor.js',
},

output: {
filename: '[name].[chunkhash].js',
chunkFilename: '[name].[chunkhash].js',
path: path.resolve(__dirname, 'dist'),
},

module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,

use: [{
loader: 'babel-loader',

options: {
presets: ['@babel/preset-env'],
}
}]
},
{
test: /\.(scss|css)$/,
use: ExtractTextPlugin.extract({
fallback: 'style',
use: 'css!sass'
}),
},
],
},

plugins: [new ExtractTextPlugin('styles-[contentHash].css'), new HtmlWebpackPlugin()],

optimization: {
minimize: true
},

optimizations: {
splitChunks: {
cacheGroups: {
common: {
name: 'common',
chunks: 'initial',
enforce: true,
minChunks: 2,
filename: 'common-[hash].min.js'
}
}
}
}
};

0 comments on commit a3093bd

Please sign in to comment.