Skip to content

Commit

Permalink
fix: Upgrade to Jest 19 (#71)
Browse files Browse the repository at this point in the history
* fix: Upgraded to Jest 19
* Removed unnecessary Jest config
* fix: temporary use absolute paths for mock requires
* build: Generate coverage report
  • Loading branch information
okonet committed Feb 24, 2017
1 parent b9d22c9 commit fe62523
Show file tree
Hide file tree
Showing 17 changed files with 139 additions and 131 deletions.
2 changes: 1 addition & 1 deletion __mocks__/inquirer/initialize.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const Rx = require('rx');
const got = require('got');
const questions = require('../../lib/utils/initial-questions');
//eslint-disable-next-line
const prompt = require('prompt.mock');
const prompt = require('./prompt.mock');
const initialConfig = jest.genMockFromModule('../../lib/utils/initial-config');


Expand Down
2 changes: 1 addition & 1 deletion lib/inquirer-prompt.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

describe('inquirer-prompt', () => {
//eslint-disable-next-line
const {init} = require('initialize.mock');
const {init} = require('../__mocks__/inquirer/initialize.mock');

it('should provide with basic options if no argument is supplied to init', async () => {
let itInits = await init(null, {
Expand Down
2 changes: 1 addition & 1 deletion lib/parser/validate-options.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe('validate-options', () => {
//eslint-disable-next-line
const {validateOptions} = require('validate-options.mock');
const {validateOptions} = require('../../__mocks__/parser/validate-options.mock');

it('should throw on fake paths', () => {
expect(() => {
Expand Down
54 changes: 28 additions & 26 deletions lib/transformations/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`transform should respect recast options 1`] = `
"
module.exports = {
devtool: \'eval\',
devtool: 'eval',
entry: [
\'./src/index\'
'./src/index'
],
output: {
path: path.join(__dirname, \'dist\'),
filename: \'index.js\'
path: path.join(__dirname, 'dist'),
filename: 'index.js'
},
module: {
rules: [{
test: /.js$/,
use: \"babel\",
include: path.join(__dirname, \'src\')
use: \\"babel\\",
include: path.join(__dirname, 'src')
}]
},
resolve: {
modules: [\'node_modules\', path.resolve(\'/src\')],
modules: ['node_modules', path.resolve('/src')],
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
}),
new webpack.optimize.LoaderOptionsPlugin({
\"debug\": true,
\"minimize\": true,
\\"debug\\": true,
\\"minimize\\": true,
})
],
debug: true
Expand All @@ -36,24 +38,24 @@ module.exports = {
exports[`transform should transform only using specified transformations 1`] = `
"
module.exports = {
devtool: \'eval\',
devtool: 'eval',
entry: [
\'./src/index\'
'./src/index'
],
output: {
path: path.join(__dirname, \'dist\'),
filename: \'index.js\'
path: path.join(__dirname, 'dist'),
filename: 'index.js'
},
module: {
rules: [{
test: /.js$/,
use: [\'babel\'],
include: path.join(__dirname, \'src\')
use: ['babel'],
include: path.join(__dirname, 'src')
}]
},
resolve: {
root: path.resolve(\'/src\'),
modules: [\'node_modules\']
root: path.resolve('/src'),
modules: ['node_modules']
},
plugins: [
new webpack.optimize.UglifyJsPlugin(),
Expand All @@ -67,31 +69,31 @@ module.exports = {
exports[`transform should transform using all transformations 1`] = `
"
module.exports = {
devtool: \'eval\',
devtool: 'eval',
entry: [
\'./src/index\'
'./src/index'
],
output: {
path: path.join(__dirname, \'dist\'),
filename: \'index.js\'
path: path.join(__dirname, 'dist'),
filename: 'index.js'
},
module: {
rules: [{
test: /.js$/,
use: \'babel\',
include: path.join(__dirname, \'src\')
use: 'babel',
include: path.join(__dirname, 'src')
}]
},
resolve: {
modules: [\'node_modules\', path.resolve(\'/src\')]
modules: ['node_modules', path.resolve('/src')]
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
sourceMap: true
}),
new webpack.optimize.LoaderOptionsPlugin({
\'debug\': true,
\'minimize\': true
'debug': true,
'minimize': true
})
],
debug: true
Expand Down
22 changes: 12 additions & 10 deletions lib/transformations/__snapshots__/utils.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`utils createLiteral should create basic literal 1`] = `
Object {
"comments": null,
Expand All @@ -20,52 +22,52 @@ Object {

exports[`utils createOrUpdatePluginByName should add an object as an argument 1`] = `
"[new Plugin({
\"foo\": true
\\"foo\\": true
})]"
`;

exports[`utils createOrUpdatePluginByName should create a new plugin with arguments 1`] = `
"{ plugins: [new Plugin({
\"foo\": \"bar\"
\\"foo\\": \\"bar\\"
})] }"
`;

exports[`utils createOrUpdatePluginByName should create a new plugin without arguments 1`] = `"{ plugins: [new Plugin()] }"`;

exports[`utils createOrUpdatePluginByName should merge options objects 1`] = `
"[new Plugin({
\"foo\": false,
\"bar\": \"baz\",
\"baz-long\": true
\\"foo\\": false,
\\"bar\\": \\"baz\\",
\\"baz-long\\": true
})]"
`;

exports[`utils createProperty should create properties for Boolean 1`] = `
"{
\"foo\": true
\\"foo\\": true
}"
`;

exports[`utils createProperty should create properties for Number 1`] = `
"{
\"foo\": -1
\\"foo\\": -1
}"
`;

exports[`utils createProperty should create properties for String 1`] = `
"{
\"foo\": \"bar\"
\\"foo\\": \\"bar\\"
}"
`;

exports[`utils createProperty should create properties for complex keys 1`] = `
"{
\"foo-bar\": \"bar\"
\\"foo-bar\\": \\"bar\\"
}"
`;

exports[`utils createProperty should create properties for non-literal keys 1`] = `
"{
1: \"bar\"
1: \\"bar\\"
}"
`;
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`bannerPlugin transforms correctly using "bannerPlugin-0" data 1`] = `
"module.exports = {
plugins: [
new webpack.BannerPlugin({
raw: true,
entryOnly: true,
\'banner\': \'Banner\'
'banner': 'Banner'
})
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`extractTextPlugin transforms correctly 1`] = `
"let ExtractTextPlugin = require(\'extract-text-webpack-plugin\');
let HTMLWebpackPlugin = require(\'html-webpack-plugin\');
"let ExtractTextPlugin = require('extract-text-webpack-plugin');
let HTMLWebpackPlugin = require('html-webpack-plugin');
module.export = {
module: {
rules: [
{
test: /\\.css$/,
test: /\\\\.css$/,
use: ExtractTextPlugin.extract({
\'fallback\': \'style-loader\',
\'use\': \'css-loader\'
'fallback': 'style-loader',
'use': 'css-loader'
})
}
]
},
plugins: [
new ExtractTextPlugin(\"styles.css\"),
new ExtractTextPlugin(\\"styles.css\\"),
]
}
"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`loaderOptionsPlugin transforms correctly using "loaderOptionsPlugin-0" data 1`] = `
"// Do not create LoaderOptionsPlugin is not necessary
module.exports = {
Expand All @@ -14,22 +16,22 @@ exports[`loaderOptionsPlugin transforms correctly using "loaderOptionsPlugin-1"
plugins: [
new webpack.optimize.UglifyJsPlugin(),
new webpack.optimize.LoaderOptionsPlugin({
foo: \'bar\',
\'debug\': true,
\'minimize\': true
foo: 'bar',
'debug': true,
'minimize': true
})
]
}
"
`;

exports[`loaderOptionsPlugin transforms correctly using "loaderOptionsPlugin-2" data 1`] = `
"// Don\'t modify LoaderOptionsPlugin
"// Don't modify LoaderOptionsPlugin
module.exports = {
plugins: [
new SomePlugin(),
new webpack.optimize.LoaderOptionsPlugin({
foo: \'bar\'
foo: 'bar'
})
]
}
Expand Down
Loading

0 comments on commit fe62523

Please sign in to comment.