Skip to content

Commit efa1b4a

Browse files
committed
fix: ignore our own warning message in error log test
1 parent ea2e4dd commit efa1b4a

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

packages/e2e-tests/build-watch/__tests__/build-watch.spec.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import {
1010
browserLogs,
1111
e2eServer
1212
} from '~utils';
13-
import { describe, test, expect } from 'vitest';
13+
14+
import * as vite from 'vite';
15+
// @ts-ignore
16+
const isRolldownVite = !!vite.rolldownVersion;
1417

1518
describe.runIf(isBuildWatch)('build-watch', () => {
1619
test('should render App', async () => {
@@ -60,6 +63,17 @@ describe.runIf(isBuildWatch)('build-watch', () => {
6063
const updateApp = editFileAndWaitForBuildWatchComplete.bind(null, 'src/App.svelte');
6164
const updateStore = editFileAndWaitForBuildWatchComplete.bind(null, 'src/stores/hmr-stores.js');
6265

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+
6377
test('should have expected initial state', async () => {
6478
// initial state, both counters 0, both labels red
6579
expect(await getText('#hmr-test-1 .counter')).toBe('0');
@@ -87,7 +101,7 @@ describe.runIf(isBuildWatch)('build-watch', () => {
87101
// color should have changed
88102
expect(await getColor('#hmr-test-1 .label')).toBe('green');
89103
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([]);
91105
});
92106

93107
test('should apply js change in HmrTest.svelte ', async () => {
@@ -97,7 +111,7 @@ describe.runIf(isBuildWatch)('build-watch', () => {
97111
);
98112
expect(await getText('#hmr-test-1 .label')).toBe('hmr-test-updated');
99113
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([]);
101115
});
102116

103117
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', () => {
113127
expect(await getText('#hmr-test-2 .counter')).toBe('0');
114128
// a third instance has been added
115129
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([]);
117131
});
118132

119133
test('should reset state of store when editing hmr-stores.js', async () => {
@@ -124,7 +138,7 @@ describe.runIf(isBuildWatch)('build-watch', () => {
124138
await updateStore((content) => `${content}\n/*trigger change*/\n`);
125139
// counter state is reset
126140
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([]);
128142
});
129143

130144
test('should work when editing script context="module"', async () => {
@@ -137,7 +151,7 @@ describe.runIf(isBuildWatch)('build-watch', () => {
137151
expect(await getText('#hmr-without-context')).toContain('x=0 y=2 slot=');
138152
expect(hmrCount('UsingNamed.svelte'), 'updates for UsingNamed.svelte').toBe(0);
139153
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([]);
141155
});
142156
});
143157
});

0 commit comments

Comments
 (0)