Skip to content

Commit

Permalink
fixup: svelte5 alias for jest
Browse files Browse the repository at this point in the history
  • Loading branch information
mcous committed May 14, 2024
1 parent b864ccb commit 7d84475
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
run: npm run test:${{ matrix.test-runner }}

- name: ▶️ Run type-checks
if: ${{ matrix.node == '20' && matrix.svelte == '4' }}
if: ${{ matrix.node == '20' && matrix.svelte == '4' && matrix.test-runner == 'vitest:jsdom' }}
run: npm run types

- name: ⬆️ Upload coverage report
Expand Down
9 changes: 8 additions & 1 deletion jest.config.cjs → jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
import { VERSION as SVELTE_VERSION } from 'svelte/compiler'

const IS_SVELTE_5 = SVELTE_VERSION >= '5'

export default {
testMatch: ['<rootDir>/src/__tests__/**/*.test.js'],
transform: {
'^.+\\.svelte$': 'svelte-jester',
Expand All @@ -10,6 +14,9 @@ module.exports = {
injectGlobals: false,
moduleNameMapper: {
'^vitest$': '<rootDir>/src/__tests__/_jest-vitest-alias.js',
'^@testing-library/svelte$': IS_SVELTE_5
? '<rootDir>/src/svelte5-index.js'
: '<rootDir>/src/index.js',
},
resetMocks: true,
restoreMocks: true,
Expand Down

0 comments on commit 7d84475

Please sign in to comment.