Skip to content

Commit a821147

Browse files
committed
Add global $t test mock
1 parent 16799e5 commit a821147

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { config } from '@vue/test-utils'
2+
3+
/**
4+
* Global mock of the $t and $tdate functions from the i18n plugin
5+
* @see https://stackoverflow.com/a/73424634/445757
6+
*/
7+
config.global.mocks = {
8+
$t: (tKey: string): string => tKey, // just return translation key
9+
$tdate: (date: string): string => date // just return translation key
10+
}

packages/theme-pink-cupcake/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export default defineConfig({
3939
reportsDirectory: './_meta/_coverage',
4040
include: ['src/**/*.*'],
4141
},
42+
setupFiles: ['src/tests/translator.setup.ts'],
4243
environment: 'happy-dom'
4344
}
4445
})

0 commit comments

Comments
 (0)