Skip to content

Commit

Permalink
Try fake timer
Browse files Browse the repository at this point in the history
  • Loading branch information
jgerigmeyer committed Nov 7, 2024
1 parent a70f6b4 commit 77d1cf4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
1 change: 1 addition & 0 deletions test/routes/page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface TestContext {

describe('Page', () => {
beforeEach<TestContext>((context) => {
vi.useFakeTimers();
context.result = render(Page);
});

Expand Down
14 changes: 1 addition & 13 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { svelteTesting } from '@testing-library/svelte/vite';
import type { PluginOption } from 'vite';
import {
coverageConfigDefaults,
defineConfig,
Expand All @@ -8,24 +7,13 @@ import {

import viteConfig from './vite.config.js';

// Run tests in browser environment
// https://github.com/testing-library/svelte-testing-library/issues/222
const vitestBrowserConditionPlugin: PluginOption = {
name: 'vite-plugin-vitest-browser-condition',
config({ resolve }) {
if (process.env.VITEST) {
resolve?.conditions?.unshift('browser');
}
},
};

/**
* @see https://vitest.dev/config/#configuration
*/
export default mergeConfig(
viteConfig,
defineConfig({
plugins: [vitestBrowserConditionPlugin, svelteTesting()],
plugins: [svelteTesting()],
test: {
include: ['./test/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
globals: true,
Expand Down

0 comments on commit 77d1cf4

Please sign in to comment.