Skip to content

Commit 9645bae

Browse files
committed
test: Add cases confirming behavior
1 parent ce7dffa commit 9645bae

File tree

5 files changed

+52
-0
lines changed

5 files changed

+52
-0
lines changed
Lines changed: 9 additions & 0 deletions
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+
</head>
6+
<body>
7+
<script prerender type="module" src="/src/index.js"></script>
8+
</body>
9+
</html>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import('./split-chunk.js');
2+
3+
export async function prerender() {
4+
return `<h1>Simple Test Result</h1>`;
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
globalThis.splitChunk = function splitChunk() {
2+
console.log('splitChunk');
3+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { defineConfig } from 'vite';
2+
import { vitePrerenderPlugin } from 'vite-prerender-plugin';
3+
4+
export default defineConfig({
5+
plugins: [vitePrerenderPlugin()],
6+
});

tests/index.test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,33 @@ test('Should support comment nodes in returned HTML', async () => {
7373
assert.match(prerenderedHtml, '<!-- With Input HTML Comment -->');
7474
});
7575

76+
test('Should support custom output filenames', async () => {
77+
await loadFixture('named-chunks', env);
78+
await writeConfig(env.tmp.path, `
79+
import { defineConfig } from 'vite';
80+
import { vitePrerenderPlugin } from 'vite-prerender-plugin';
81+
82+
export default defineConfig({
83+
build: {
84+
rollupOptions: {
85+
output: {
86+
chunkFileNames: 'chunks/[name].[hash].js',
87+
}
88+
}
89+
},
90+
plugins: [vitePrerenderPlugin()],
91+
});
92+
`);
93+
await viteBuild(env.tmp.path);
94+
95+
let message = '';
96+
try {
97+
await viteBuild(env.tmp.path);
98+
} catch (error) {
99+
message = error.message;
100+
}
101+
102+
assert.match(message, '');
103+
});
104+
76105
test.run();

0 commit comments

Comments
 (0)