Ensure that all tests pass for webpack2

Use sort mode "dependency" as default for webpack2
This commit is contained in:
Jan Nicklas 2016-03-22 19:02:00 +01:00
parent 40b065808c
commit 831cbdecb8
5 changed files with 23 additions and 24 deletions

View File

@ -3,3 +3,7 @@ node_js:
- "0.12" - "0.12"
- "0.10" - "0.10"
- "4" - "4"
script:
- npm test
- npm rm webpack && npm i webpack@beta || true
- npm test

View File

@ -20,4 +20,4 @@ install:
test_script: test_script:
- node --version - node --version
- npm --version - npm --version
- npm test - npm test

View File

@ -20,6 +20,8 @@ var HtmlWebpackPlugin = require('../index.js');
var OUTPUT_DIR = path.join(__dirname, '../dist'); var OUTPUT_DIR = path.join(__dirname, '../dist');
jasmine.getEnv().defaultTimeoutInterval = 5000;
function testHtmlPlugin (webpackConfig, expectedResults, outputFile, done, expectErrors, expectWarnings) { function testHtmlPlugin (webpackConfig, expectedResults, outputFile, done, expectErrors, expectWarnings) {
outputFile = outputFile || 'index.html'; outputFile = outputFile || 'index.html';
webpack(webpackConfig, function (err, stats) { webpack(webpackConfig, function (err, stats) {
@ -106,7 +108,7 @@ describe('HtmlWebpackPlugin', function () {
}, ['<script src="util_bundle.js"', '<script src="app_bundle.js"'], null, done); }, ['<script src="util_bundle.js"', '<script src="app_bundle.js"'], null, done);
}); });
it('allows you to specify a custom loader', function (done) { it('allows you to specify a custom loader without injection', function (done) {
testHtmlPlugin({ testHtmlPlugin({
entry: { entry: {
app: path.join(__dirname, 'fixtures/index.js') app: path.join(__dirname, 'fixtures/index.js')
@ -117,7 +119,7 @@ describe('HtmlWebpackPlugin', function () {
}, },
plugins: [new HtmlWebpackPlugin({ plugins: [new HtmlWebpackPlugin({
inject: false, inject: false,
template: 'underscore-template-loader!' + path.join(__dirname, 'fixtures/test.html') template: 'jade-loader!' + path.join(__dirname, 'fixtures/template.jade')
})] })]
}, },
['<script src="app_bundle.js', 'Some unique text'], null, done); ['<script src="app_bundle.js', 'Some unique text'], null, done);
@ -147,7 +149,7 @@ describe('HtmlWebpackPlugin', function () {
}, },
module: { module: {
loaders: [ loaders: [
{test: /\.html$/, loader: 'underscore-template-loader'} {test: /\.jade$/, loader: 'jade-loader'}
] ]
}, },
output: { output: {
@ -156,7 +158,7 @@ describe('HtmlWebpackPlugin', function () {
}, },
plugins: [new HtmlWebpackPlugin({ plugins: [new HtmlWebpackPlugin({
inject: false, inject: false,
template: path.join(__dirname, 'fixtures/test.html') template: path.join(__dirname, 'fixtures/template.jade')
})] })]
}, },
['<script src="app_bundle.js', 'Some unique text'], null, done); ['<script src="app_bundle.js', 'Some unique text'], null, done);
@ -871,7 +873,7 @@ describe('HtmlWebpackPlugin', function () {
plugins: [ plugins: [
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
inject: false, inject: false,
template: 'underscore-template-loader!' + path.join(__dirname, 'fixtures/custom_file.html') template: 'jade!' + path.join(__dirname, 'fixtures/template.jade')
}), }),
examplePlugin examplePlugin
] ]
@ -1059,10 +1061,10 @@ describe('HtmlWebpackPlugin', function () {
template: path.join(__dirname, 'fixtures/non-existing-template.html') template: path.join(__dirname, 'fixtures/non-existing-template.html')
}) })
] ]
}, ["Child compilation failed:\n Entry module not found: Error: Cannot resolve 'file' or 'directory'"], null, done, true); }, ['Child compilation failed:\n Entry module not found:'], null, done, true);
}); });
it('should sort the chunks', function (done) { it('should sort the chunks in auto mode', function (done) {
testHtmlPlugin({ testHtmlPlugin({
entry: { entry: {
util: path.join(__dirname, 'fixtures/util.js'), util: path.join(__dirname, 'fixtures/util.js'),

View File

@ -1,16 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<title>Test</title>
</head>
<body>
<p>Some unique text</p>
<% for(var i = 0; i <htmlWebpackPlugin.files.js.length; i++) {
var filename = htmlWebpackPlugin.files.js[i];
if (filename.indexOf('funky-script') < 0) continue;%>
<script src="<%=filename%>"></script>
<% } %>
<script src="<%=htmlWebpackPlugin.files.chunks.app.entry%>"></script>
</body>
</html>

9
spec/fixtures/template.jade vendored Normal file
View File

@ -0,0 +1,9 @@
doctype html
html
head
meta(http-equiv="Content-type" content="text/html; charset=utf-8")
title Demo
body
p Some unique text
each jsFile in htmlWebpackPlugin.files.js
script(src!=jsFile)