This repository has been archived by the owner on Mar 17, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: standardize test configuration (#214)
- Loading branch information
1 parent
f321874
commit 52c882e
Showing
26 changed files
with
3,606 additions
and
1,202 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Loader Defaults 1`] = `"module.exports = __webpack_public_path__ + \\"9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";"`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import fileLoader from '../src'; | ||
import cjsFileLoader from '../src/cjs'; | ||
import loader from '../src'; | ||
import CJSLoader from '../src/cjs'; | ||
|
||
describe('cjs', () => { | ||
describe('CJS', () => { | ||
it('should export loader', () => { | ||
expect(cjsFileLoader).toEqual(fileLoader); | ||
expect(CJSLoader).toEqual(loader); | ||
}); | ||
|
||
it('should export `raw` flag', () => { | ||
expect(cjsFileLoader.raw).toEqual(true); | ||
expect(CJSLoader.raw).toEqual(true); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* eslint-disable */ | ||
import svg from '../file.svg'; | ||
|
||
export default svg |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* eslint-disable */ | ||
import png from './file.png'; | ||
|
||
export default png; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* eslint-disable | ||
import/order, | ||
multiline-ternary, | ||
no-param-reassign, | ||
*/ | ||
import del from 'del'; | ||
import path from 'path'; | ||
import webpack from 'webpack'; | ||
import MemoryFS from 'memory-fs'; | ||
|
||
const module = (config) => { | ||
return { | ||
rules: config.rules || config.loader | ||
? [ | ||
{ | ||
test: config.loader.test || /\.txt$/, | ||
use: { | ||
loader: path.resolve(__dirname, '../../src'), | ||
options: config.loader.options || {}, | ||
}, | ||
}, | ||
] | ||
: [], | ||
}; | ||
}; | ||
|
||
const plugins = config => ([ | ||
new webpack.optimize.CommonsChunkPlugin({ | ||
name: ['runtime'], | ||
minChunks: Infinity, | ||
}), | ||
].concat(config.plugins || [])); | ||
|
||
const output = (config) => { | ||
return { | ||
path: path.resolve( | ||
__dirname, | ||
`../outputs/${config.output ? config.output : ''}`, | ||
), | ||
filename: '[name].bundle.js', | ||
}; | ||
}; | ||
|
||
export default function (fixture, config, options) { | ||
// webpack Config | ||
config = { | ||
devtool: config.devtool || 'sourcemap', | ||
context: path.resolve(__dirname, '..', 'fixtures'), | ||
entry: `./${fixture}`, | ||
output: output(config), | ||
module: module(config), | ||
plugins: plugins(config), | ||
}; | ||
// Compiler Options | ||
options = Object.assign({ output: false }, options); | ||
|
||
if (options.output) del.sync(config.output.path); | ||
|
||
const compiler = webpack(config); | ||
|
||
if (!options.output) compiler.outputFileSystem = new MemoryFS(); | ||
|
||
return new Promise((resolve, reject) => compiler.run((err, stats) => { | ||
if (err) reject(err); | ||
|
||
resolve(stats); | ||
})); | ||
} |
Oops, something went wrong.