Skip to content

Commit c96bbe7

Browse files
Detect warnings in Svelte tests
1 parent e7a13b4 commit c96bbe7

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

integrations/vite/svelte.test.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ test(
6464
'src/other.css': css`
6565
.local {
6666
@apply text-red-500;
67-
animation: 2s ease-in-out 0s infinite localKeyframes;
67+
animation: 2s ease-in-out infinite localKeyframes;
6868
}
6969
7070
:global(.global) {
7171
@apply text-green-500;
72-
animation: 2s ease-in-out 0s infinite globalKeyframes;
72+
animation: 2s ease-in-out infinite globalKeyframes;
7373
}
7474
7575
@keyframes -global-globalKeyframes {
@@ -93,18 +93,21 @@ test(
9393
},
9494
},
9595
async ({ exec, fs, expect }) => {
96-
await exec('pnpm vite build')
96+
let output = await exec('pnpm vite build')
9797

9898
let files = await fs.glob('dist/**/*.css')
9999
expect(files).toHaveLength(1)
100100

101101
await fs.expectFileToContain(files[0][0], [
102102
candidate`underline`,
103-
'.global{color:var(--color-green-500);animation:2s ease-in-out 0s infinite globalKeyframes}',
104-
/\.local.svelte-.*\{color:var\(--color-red-500\);animation:2s ease-in-out 0s infinite svelte-.*-localKeyframes\}/,
103+
'.global{color:var(--color-green-500);animation:2s ease-in-out infinite globalKeyframes}',
104+
/\.local.svelte-.*\{color:var\(--color-red-500\);animation:2s ease-in-out infinite svelte-.*-localKeyframes\}/,
105105
/@keyframes globalKeyframes\{/,
106106
/@keyframes svelte-.*-localKeyframes\{/,
107107
])
108+
109+
// Should not print any warnings
110+
expect(output).not.toContain('vite-plugin-svelte')
108111
},
109112
)
110113

@@ -172,12 +175,12 @@ test(
172175
'src/other.css': css`
173176
.local {
174177
@apply text-red-500;
175-
animation: 2s ease-in-out 0s infinite localKeyframes;
178+
animation: 2s ease-in-out infinite localKeyframes;
176179
}
177180
178181
:global(.global) {
179182
@apply text-green-500;
180-
animation: 2s ease-in-out 0s infinite globalKeyframes;
183+
animation: 2s ease-in-out infinite globalKeyframes;
181184
}
182185
183186
@keyframes -global-globalKeyframes {
@@ -210,10 +213,10 @@ test(
210213
let [, css] = files[0]
211214
expect(css).toContain(candidate`underline`)
212215
expect(css).toContain(
213-
'.global{color:var(--color-green-500);animation:2s ease-in-out 0s infinite globalKeyframes}',
216+
'.global{color:var(--color-green-500);animation:2s ease-in-out infinite globalKeyframes}',
214217
)
215218
expect(css).toMatch(
216-
/\.local.svelte-.*\{color:var\(--color-red-500\);animation:2s ease-in-out 0s infinite svelte-.*-localKeyframes\}/,
219+
/\.local.svelte-.*\{color:var\(--color-red-500\);animation:2s ease-in-out infinite svelte-.*-localKeyframes\}/,
217220
)
218221
expect(css).toMatch(/@keyframes globalKeyframes\{/)
219222
expect(css).toMatch(/@keyframes svelte-.*-localKeyframes\{/)
@@ -235,10 +238,10 @@ test(
235238
let [, css] = files[0]
236239
expect(css).toContain(candidate`font-bold`)
237240
expect(css).toContain(
238-
'.global{color:var(--color-green-500);animation:2s ease-in-out 0s infinite globalKeyframes}',
241+
'.global{color:var(--color-green-500);animation:2s ease-in-out infinite globalKeyframes}',
239242
)
240243
expect(css).toMatch(
241-
/\.local.svelte-.*\{color:var\(--color-red-500\);animation:2s ease-in-out 0s infinite svelte-.*-localKeyframes\}/,
244+
/\.local.svelte-.*\{color:var\(--color-red-500\);animation:2s ease-in-out infinite svelte-.*-localKeyframes\}/,
242245
)
243246
expect(css).toMatch(/@keyframes globalKeyframes\{/)
244247
expect(css).toMatch(/@keyframes svelte-.*-localKeyframes\{/)

0 commit comments

Comments
 (0)