Skip to content

Commit

Permalink
Fix Vite test on main (#6478)
Browse files Browse the repository at this point in the history
  • Loading branch information
YohannParis authored Feb 6, 2025
1 parent 75022be commit 96ce2d8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = {
'no-plusplus': 'off',
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-unused-vars': ['warn', { 'argsIgnorePattern': '^_' }],
'prefer-destructuring': 'off',
'vuejs-accessibility/click-events-have-key-events': 'off',
'vuejs-accessibility/label-has-for': 'off',
Expand Down
16 changes: 16 additions & 0 deletions packages/client/hmi-client/tests/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class MockWorker {
onmessage: ((event: MessageEvent) => void) | null = null;

onerror: ((event: ErrorEvent) => void) | null = null;

postMessage(_: unknown): void {
// Simulate worker behavior if needed
}

terminate(): void {
// Simulate worker termination if needed
}
}

// Assign the mock to global.Worker
(global as any).Worker = MockWorker;
5 changes: 3 additions & 2 deletions packages/client/hmi-client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default defineConfig({
}
}
}),
// By default SVGs are imported as URL in order to easily reference them in img tags
// By default, SVGs are imported as URL in order to easily reference them in img tags
// In order to import SVGs as components you must add '?component' as a suffix of an SVG's path
svgLoader({ defaultImport: 'url' })
],
Expand All @@ -97,6 +97,7 @@ export default defineConfig({
outputFile: {
junit: './tests/unit/reports/junit-report.xml'
},
environment: 'jsdom'
environment: 'jsdom', // Ensures a browser-like environment
setupFiles: './tests/setup.ts' // Points to a test setup file
}
});

0 comments on commit 96ce2d8

Please sign in to comment.