Skip to content

fix: handle emitCss in svelte config #194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 14, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: tests 3
  • Loading branch information
bluwy committed Oct 13, 2021
commit 6de69a8e09b71baf34a95242c71cafb716a49829
28 changes: 11 additions & 17 deletions packages/e2e-tests/hmr/__tests__/hmr.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,22 @@ test('should render dynamic import', async () => {
await dynamicImportButton.click();
await untilUpdated(() => getText('#dynamic-import .label'), 'dynamic-import');
});

test('should not have failed requests', async () => {
browserLogs.forEach((msg) => {
expect(msg).not.toMatch('404');
});
});

test('should work with emitCss: false in svelte config', async () => {
addFile('svelte.config.cjs', `module.exports={emitCss:false}`);
await sleep(isWin ? 1000 : 500); // adding config restarts server, give it some time
await page.goto(viteTestUrl, { waitUntil: 'networkidle' });
await sleep(50);
expect(await getColor(`#hmr-test-1 .label`)).toBe('red');
removeFile('svelte.config.cjs');
});

if (!isBuild) {
describe('hmr', () => {
const updateHmrTest = editFileAndWaitForHmrComplete.bind(null, 'src/components/HmrTest.svelte');
Expand Down Expand Up @@ -123,7 +133,7 @@ if (!isBuild) {
expect(await getText(`#hmr-test-3 .counter`)).toBe('0');
});

test('should work with emitCss: false in vite config', async () => {
test('should work with emitCss: false', async () => {
await editViteConfig((c) => c.replace('svelte()', 'svelte({emitCss:false})'));
expect(await getText(`#hmr-test-1 .counter`)).toBe('0');
expect(await getColor(`#hmr-test-1 .label`)).toBe('green');
Expand All @@ -135,22 +145,6 @@ if (!isBuild) {
expect(await getText(`#hmr-test-1 .counter`)).toBe('1');
});

test('should work with emitCss: false in svelte config', async () => {
await addFile('svelte.config.cjs', `module.exports = {emitCss:false}`);
await sleep(isWin ? 1000 : 500); // adding config restarts server, give it some time
await page.goto(viteTestUrl, { waitUntil: 'networkidle' });
await sleep(50);
expect(await getText(`#hmr-test-1 .counter`)).toBe('0');
expect(await getColor(`#hmr-test-1 .label`)).toBe('green');
await (await getEl(`#hmr-test-1 .increment`)).click();
await sleep(50);
expect(await getText(`#hmr-test-1 .counter`)).toBe('1');
await updateHmrTest((content) => content.replace('color: green', 'color: red'));
expect(await getColor(`#hmr-test-1 .label`)).toBe('red');
expect(await getText(`#hmr-test-1 .counter`)).toBe('1');
await removeFile('svelte.config.cjs');
});

test('should detect changes in svelte config and restart', async () => {
const injectPreprocessor = ({ content, filename }) => {
if (filename && filename.includes('App.svelte')) {
Expand Down