Skip to content

Commit 14ade7f

Browse files
committed
test: html-webpack-plugin integration
1 parent 0ae4443 commit 14ade7f

File tree

5 files changed

+286
-9
lines changed

5 files changed

+286
-9
lines changed

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"cache-loader": "^4.1.0",
5252
"css-loader": "^4.3.0",
5353
"file-loader": "^6.1.0",
54+
"html-webpack-plugin": "^4.5.0",
5455
"jest": "^26.4.1",
5556
"jsdom": "^16.4.0",
5657
"lint-staged": "^10.3.0",

Diff for: test/edgeCases.spec.ts

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { bundle, mockBundleAndRun, normalizeNewline } from './utils'
1+
import * as path from 'path'
2+
import HTMLPlugin from 'html-webpack-plugin'
3+
import { mfs, bundle, mockBundleAndRun, normalizeNewline } from './utils'
24

35
// @ts-ignore
46
function assertComponent({
@@ -111,7 +113,21 @@ test('should not duplicate css modules value imports', async () => {
111113
})
112114

113115
// #1213
114-
test.todo('html-webpack-plugin')
116+
test('html-webpack-plugin', async () => {
117+
await bundle({
118+
entry: 'basic.vue',
119+
plugins: [
120+
new HTMLPlugin({
121+
inject: true,
122+
template: path.resolve(__dirname, 'fixtures/index.html'),
123+
filename: 'output.html',
124+
}),
125+
],
126+
})
127+
128+
const html = mfs.readFileSync('/output.html', 'utf-8')
129+
expect(html).toMatch('test.build.js')
130+
})
115131

116132
// #1239
117133
test('usage with null-loader', async () => {

Diff for: test/fixtures/index.html

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title></title>
6+
</head>
7+
<body>
8+
</body>
9+
</html>

Diff for: test/utils.ts

+2
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,5 @@ export function normalizeNewline(input: string): string {
167167
export function genId(fixtureName: string): string {
168168
return hash(path.join('test', 'fixtures', fixtureName).replace(/\\/g, '/'))
169169
}
170+
171+
export { mfs }

0 commit comments

Comments
 (0)