Skip to content

Commit

Permalink
chore: tweak test config for hmr test run (#12423)
Browse files Browse the repository at this point in the history
* conflict

* conflict

* lint

* add comments

* Update packages/svelte/tests/runtime-runes/samples/spread-props/_config.js

Co-authored-by: Rich Harris <[email protected]>

---------

Co-authored-by: Rich Harris <[email protected]>
  • Loading branch information
trueadm and Rich-Harris authored Jul 12, 2024
1 parent 7ea418b commit e8453e7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { test } from '../../test';

export default test({
compileOptions: {
// override process.env.HMR — this test only passes in prod mode because in dev mode we generate a helpful error
dev: false
},

get props() {
return { componentName: 'Sub' };
},
Expand Down
6 changes: 4 additions & 2 deletions packages/svelte/tests/runtime-legacy/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,13 @@ export function runtime_suite(runes: boolean) {
}

async function common_setup(cwd: string, runes: boolean | undefined, config: RuntimeTest) {
const force_hmr = process.env.HMR && config.compileOptions?.dev !== false && !config.error;

const compileOptions: CompileOptions = {
generate: 'client',
rootDir: cwd,
dev: process.env.HMR ? true : undefined,
hmr: process.env.HMR ? true : undefined,
dev: force_hmr ? true : undefined,
hmr: force_hmr ? true : undefined,
...config.compileOptions,
immutable: config.immutable,
accessors: 'accessors' in config ? config.accessors : true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { flushSync } from 'svelte';
import { test } from '../../test';

export default test({
compileOptions: {
// override process.env.HMR — this test only passes in prod mode, because in dev we add `$destroy` methods etc
dev: false
},

html: `<button>Toggle</button><div>Hello\nworld</div>`,

async test({ assert, target, logs }) {
Expand Down

0 comments on commit e8453e7

Please sign in to comment.