0π
I Think itβs good to mount the component before every test, because this way there will be no sideeffects to a new test from a previous one.
But you could do something like this to not duplicate code:
const expectedValues = [
{ link: '', expects: false },
{ link: 'www.google.com', expects: true },
....
]
expectedValues.forEach(({ link, expects }) => {
it(`should evaluate ${expects} for link:${link} `, () => {
const wrapper = mount(MerchandisingArticle, {
propsData: {
article: {
link
}
}
})
expect(wrapper.find("a").exists()).to.equal(expects);
})
})
This way you can also easily add new test cases.
Source:stackexchange.com