@@ -10,7 +10,10 @@ import {
10
10
browserLogs ,
11
11
e2eServer
12
12
} from '~utils' ;
13
- import { describe , test , expect } from 'vitest' ;
13
+
14
+ import * as vite from 'vite' ;
15
+ // @ts -ignore
16
+ const isRolldownVite = ! ! vite . rolldownVersion ;
14
17
15
18
describe . runIf ( isBuildWatch ) ( 'build-watch' , ( ) => {
16
19
test ( 'should render App' , async ( ) => {
@@ -60,6 +63,17 @@ describe.runIf(isBuildWatch)('build-watch', () => {
60
63
const updateApp = editFileAndWaitForBuildWatchComplete . bind ( null , 'src/App.svelte' ) ;
61
64
const updateStore = editFileAndWaitForBuildWatchComplete . bind ( null , 'src/stores/hmr-stores.js' ) ;
62
65
66
+ const getWatchErrors = ( ) =>
67
+ isRolldownVite
68
+ ? e2eServer . logs . watch . err . filter (
69
+ ( m ) =>
70
+ ! [
71
+ 'Support for rolldown-vite in vite-plugin-svelte is experimental' ,
72
+ 'See https://github.com/sveltejs/vite-plugin-svelte/issues/1143'
73
+ ] . some ( ( s ) => m . includes ( s ) )
74
+ )
75
+ : e2eServer . logs . watch . err ;
76
+
63
77
test ( 'should have expected initial state' , async ( ) => {
64
78
// initial state, both counters 0, both labels red
65
79
expect ( await getText ( '#hmr-test-1 .counter' ) ) . toBe ( '0' ) ;
@@ -87,7 +101,7 @@ describe.runIf(isBuildWatch)('build-watch', () => {
87
101
// color should have changed
88
102
expect ( await getColor ( '#hmr-test-1 .label' ) ) . toBe ( 'green' ) ;
89
103
expect ( await getColor ( '#hmr-test-2 .label' ) ) . toBe ( 'green' ) ;
90
- expect ( e2eServer . logs . watch . err , 'error log of `build --watch` is not empty' ) . toEqual ( [ ] ) ;
104
+ expect ( getWatchErrors ( ) , 'error log of `build --watch` is not empty' ) . toEqual ( [ ] ) ;
91
105
} ) ;
92
106
93
107
test ( 'should apply js change in HmrTest.svelte ' , async ( ) => {
@@ -97,7 +111,7 @@ describe.runIf(isBuildWatch)('build-watch', () => {
97
111
) ;
98
112
expect ( await getText ( '#hmr-test-1 .label' ) ) . toBe ( 'hmr-test-updated' ) ;
99
113
expect ( await getText ( '#hmr-test-2 .label' ) ) . toBe ( 'hmr-test-updated' ) ;
100
- expect ( e2eServer . logs . watch . err , 'error log of `build --watch` is not empty' ) . toEqual ( [ ] ) ;
114
+ expect ( getWatchErrors ( ) , 'error log of `build --watch` is not empty' ) . toEqual ( [ ] ) ;
101
115
} ) ;
102
116
103
117
test ( 'should reset state of external store used by HmrTest.svelte when editing App.svelte' , async ( ) => {
@@ -113,7 +127,7 @@ describe.runIf(isBuildWatch)('build-watch', () => {
113
127
expect ( await getText ( '#hmr-test-2 .counter' ) ) . toBe ( '0' ) ;
114
128
// a third instance has been added
115
129
expect ( await getText ( '#hmr-test-3 .counter' ) ) . toBe ( '0' ) ;
116
- expect ( e2eServer . logs . watch . err , 'error log of `build --watch` is not empty' ) . toEqual ( [ ] ) ;
130
+ expect ( getWatchErrors ( ) , 'error log of `build --watch` is not empty' ) . toEqual ( [ ] ) ;
117
131
} ) ;
118
132
119
133
test ( 'should reset state of store when editing hmr-stores.js' , async ( ) => {
@@ -124,7 +138,7 @@ describe.runIf(isBuildWatch)('build-watch', () => {
124
138
await updateStore ( ( content ) => `${ content } \n/*trigger change*/\n` ) ;
125
139
// counter state is reset
126
140
expect ( await getText ( '#hmr-test-2 .counter' ) ) . toBe ( '0' ) ;
127
- expect ( e2eServer . logs . watch . err , 'error log of `build --watch` is not empty' ) . toEqual ( [ ] ) ;
141
+ expect ( getWatchErrors ( ) , 'error log of `build --watch` is not empty' ) . toEqual ( [ ] ) ;
128
142
} ) ;
129
143
130
144
test ( 'should work when editing script context="module"' , async ( ) => {
@@ -137,7 +151,7 @@ describe.runIf(isBuildWatch)('build-watch', () => {
137
151
expect ( await getText ( '#hmr-without-context' ) ) . toContain ( 'x=0 y=2 slot=' ) ;
138
152
expect ( hmrCount ( 'UsingNamed.svelte' ) , 'updates for UsingNamed.svelte' ) . toBe ( 0 ) ;
139
153
expect ( hmrCount ( 'UsingDefault.svelte' ) , 'updates for UsingDefault.svelte' ) . toBe ( 0 ) ;
140
- expect ( e2eServer . logs . watch . err , 'error log of `build --watch` is not empty' ) . toEqual ( [ ] ) ;
154
+ expect ( getWatchErrors ( ) , 'error log of `build --watch` is not empty' ) . toEqual ( [ ] ) ;
141
155
} ) ;
142
156
} ) ;
143
157
} ) ;
0 commit comments