Skip to content

Add additionalOptions test example #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
afontcu opened this issue Jun 29, 2019 · 4 comments
Closed

Add additionalOptions test example #49

afontcu opened this issue Jun 29, 2019 · 4 comments
Labels
good first issue Good for newcomers

Comments

@afontcu
Copy link
Member

afontcu commented Jun 29, 2019

Adding a test example for additionalOptions feature (#48 #47) would both (1) show how to use it and (2) increase code coverage.

I guess using vue-i18n as a example would be great.

@afontcu afontcu added the good first issue Good for newcomers label Jun 29, 2019
@makeupsomething
Copy link
Contributor

I can work on this as I actually implemented myself today. Not sure if I did it correctly or not though.

import Vue from 'vue'
import Vuei18n from 'vue-i18n'
import ja from '@/translations/ja'

Vue.use(Vuei18n)

const i18n = new Vuei18n({
    locale: 'en',
    messages: {
        ja,
    },
})

import {cleanup, render, fireEvent} from '@testing-library/vue'

afterEach(cleanup)

test('can navigate to signup page from welcome page', async () => {
    const {queryByTestId, getByText, debug} = render(
        App,
        {
            routes,
            store,
            i18n,
        },
        vue => vue.use(Vuei18n),
    )
})

If theres a better way let me know and I can tidy this up and add to the tests

@afontcu
Copy link
Member Author

afontcu commented Jul 10, 2019

Hi! Thank you for taking this :)

Notice how, in your snippet, you are using an external Vue instance to register i18n, so you are not actually using the instance exposed by Vue Testing Library. Notice how, in issue #47, the example suggests returning { i18n } from the callback function. This is the feature we added on #48.

Long story short: You shouldn't import and use external Vue, but rather use the Vue instance provided in the callback function. Then, create the config there, and return the desired object keys.

If you want, open up a PR and we can work from there :)

Thanks!

@makeupsomething
Copy link
Contributor

Hi!

Yes, I was sure that I should not be importing the external Vue to create the i18n instance but could not figure out how to create it any other way. I had not seen #47 at the time but that is clearly the correct way to create it.

Il adjust things and create a PR over the weekend.

@afontcu
Copy link
Member Author

afontcu commented Jul 17, 2019

Closed in #58

@afontcu afontcu closed this as completed Jul 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants