intlify / vue-i18n-jest

:globe_with_meridians: vue-jest wrapper for i18n custom blocks
MIT License
7 stars 4 forks source link

Custom transformer (this project) never appears to run #51

Open marr opened 2 years ago

marr commented 2 years ago

Hi, I have a vue2 project that I'm trying to run tests on and I use the following:

Jest 28 @vue/vue2-jest@28 vue-i18n-jest@1.1.1 vue-i18n@8 @vue/test-utils@1.3.0

I have added to my jest.config.js the following:

 globals: {
    '@vue/vue2-jest': {
      transform: {
        'i18n': 'vue-i18n-jest'
      }
    }
  },
  transform: {
     '^.+\\.vue$': '@vue/vue2-jest'
  }

note: I also tried the vue-jest key in the globals section with the same results.

My tests fail with the following error:

TypeError: Cannot read properties of undefined (reading 't')

line in question:

data() {
    headers: [
      {
         text: this.$i18n.t('admin.users.headers.name'),

My test render call:

it('renders', () => {
  const wrapper = shallowMount(UserList, {
    Vue,
    propsData: {
      users,
    },
  });

Thank you for any guidance.