Skip to content

Commit 2b42f9b

Browse files
committed
chore: add test
1 parent 9fee379 commit 2b42f9b

File tree

8 files changed

+90
-16
lines changed

8 files changed

+90
-16
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { fileURLToPath } from 'node:url';
2+
import { build, type Rollup, type InlineConfig } from 'vite';
3+
import { svelte } from '@sveltejs/vite-plugin-svelte';
4+
import { isBuild } from '~utils';
5+
6+
test.runIf(isBuild)('build-multiple', async () => {
7+
const sharedConfig: InlineConfig = {
8+
configFile: false,
9+
root: fileURLToPath(new URL('../', import.meta.url)),
10+
build: {
11+
write: false
12+
},
13+
logLevel: 'silent',
14+
plugins: [svelte()]
15+
};
16+
17+
// Ensure two builds work as expected and have no build errors
18+
19+
const output1 = await build({ ...sharedConfig, mode: 'production' });
20+
expect(output1).toHaveProperty('output');
21+
expect(
22+
(output1 as Rollup.RollupOutput).output.find(
23+
(c) => c.type === 'chunk' && c.code.includes('mode: production')
24+
)
25+
).toBeDefined();
26+
27+
const output2 = await build({ ...sharedConfig, mode: 'staging' });
28+
expect(output2).toHaveProperty('output');
29+
expect(
30+
(output2 as Rollup.RollupOutput).output.find(
31+
(c) => c.type === 'chunk' && c.code.includes('mode: staging')
32+
)
33+
).toBeDefined();
34+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" href="/favicon.png" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Svelte App</title>
8+
</head>
9+
<body>
10+
<script type="module" src="/src/index.js"></script>
11+
</body>
12+
</html>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "e2e-tests-build-multiple",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite dev",
8+
"build": "vite build",
9+
"preview": "vite preview"
10+
},
11+
"devDependencies": {
12+
"@sveltejs/vite-plugin-svelte": "workspace:^",
13+
"svelte": "^5.38.2",
14+
"vite": "^7.1.2"
15+
}
16+
}
3.05 KB
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p>mode: {import.meta.env.MODE}</p>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import App from './App.svelte';
2+
import { mount } from 'svelte';
3+
mount(App, { target: document.body });
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { svelte } from '@sveltejs/vite-plugin-svelte';
2+
import { defineConfig } from 'vite';
3+
4+
export default defineConfig({
5+
plugins: [svelte()]
6+
});

pnpm-lock.yaml

Lines changed: 18 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)