You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/packages/svelte/tests/runtime-runes/samples/non-local-mutation-discouraged/_config.js

37 lines
761 B

import { flushSync } from 'svelte';
import { test } from '../../test';
/** @type {typeof console.trace} */
let trace;
export default test({
html: `<button>clicks: 0</button>`,
compileOptions: {
dev: true
},
before_test: () => {
trace = console.trace;
console.trace = () => {};
},
after_test: () => {
console.trace = trace;
},
test({ assert, target, warnings }) {
const btn = target.querySelector('button');
flushSync(() => {
btn?.click();
});
assert.htmlEqual(target.innerHTML, `<button>clicks: 1</button>`);
assert.deepEqual(warnings, [
'Counter.svelte mutated a value owned by main.svelte. This is strongly discouraged. Consider passing values to child components with `bind:`, or use a callback instead'
]);
}
});