Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mount): correctly work with component throwing on mount
* workaround for vuejs/core#7020
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { describe, expect, it } from 'vitest' | ||
import { defineComponent } from 'vue' | ||
import { mount } from '../src' | ||
|
||
describe('mount: general tests', () => { | ||
it('correctly handles component, throwing on mount', () => { | ||
// See https://github.com/vuejs/core/issues/7020 | ||
const ThrowingComponent = defineComponent({ | ||
props: ['blowup'], | ||
mounted() { | ||
if (this.blowup) { | ||
throw new Error('Boom!') | ||
} | ||
}, | ||
template: '<div>hello</div>' | ||
}) | ||
|
||
expect(() => | ||
mount(ThrowingComponent, { props: { blowup: true } }) | ||
).toThrow() | ||
|
||
const wrapper = mount(ThrowingComponent, { props: { blowup: false } }) | ||
|
||
expect(wrapper.html()).toBe('<div>hello</div>') | ||
}) | ||
}) |