Skip to content

-added a test to check the error from the issue 1820 #1832

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
wants to merge 6 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions test/specs/wrapper/find.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
isRunningChrome
} from '~resources/utils'
import { itDoNotRunIf, itSkipIf } from 'conditional-specs'
import VueRouter from 'vue-router'

describeWithShallowAndMount('find', mountingMethod => {
it('returns a Wrapper matching tag selector passed', () => {
Expand Down Expand Up @@ -279,6 +280,68 @@ describeWithShallowAndMount('find', mountingMethod => {
}
)

it('have no better name right now, but this does not fail.........', () => {
const TestComponentToFind = {
render: h => h('div'),
name: 'test-component-to-find'
}
const TestComponent = {
template: `
<div>
<test-component-to-find/>
<test-component-to-find/>
<test-component-to-find/>
</div>'
`,
components: {
TestComponentToFind
},
name: 'test-component'
}

const wrapper = mountingMethod(TestComponent)

expect(
wrapper
.findAllComponents({ name: 'test-component-to-find' })
.at(0)
.exists()
).toBe(true)
})

it('ok this test fails', async () => {
const TestComponentToFind = {
render: h => h('div'),
name: 'test-component-to-find'
}
const localVue = createLocalVue()
localVue.use(VueRouter)
const routes = [
{
path: '/a/b',
name: 'ab',
component: TestComponentToFind
}
]
const router = new VueRouter({ routes })
// and this will not work with shallowMount because router view gets stubbed! How can I just test mount?
const wrapper = mountingMethod(
Copy link
Member

@lmiller1990 lmiller1990 Apr 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mountingMethod is both mount and shallowMount. We run all tests for both. If you don't want to run the test for one, just import the one you want on line 2 from packages/src/test-utils. Or you can do a check with the doNotTestIf helpers.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok done that.

{
template: '<router-view/>'
},
{
localVue,
router
}
)

try {
await router.push('/a/b')
} catch (e) {} // this will throw NavigationDuplicated the second time, dunno how to fix it

expect(wrapper.findComponent(TestComponentToFind).exists()).toBe(true)
})

it('returns extended functional component', () => {
const TestFunctionalComponent = Vue.extend({
render: h => h('div'),
Expand Down