@@ -168,20 +168,33 @@ describe("frontmatter-markdown-loader", () => {
168168
169169 it ( "throw if vue-template|compiler is not installed in the project" , ( ) => {
170170 jest . mock ( 'vue-template-compiler' , ( ) => {
171- throw new Error ( ) ;
171+ const error = new Error ( )
172+ error . code = 'MODULE_NOT_FOUND'
173+ throw error
172174 } ) ;
173175 expect ( ( ) => {
174176 load ( markdownWithFrontmatter , contextEnablingVueRenderFunctions ( ) ) ;
175- } ) . toThrow ( ) ;
177+ } ) . toThrow ( / F a i l e d t o i m p o r t / ) ;
176178 } ) ;
177179
178180 it ( "throw if @vue/component-compiler-utils is not installed in the project" , ( ) => {
179181 jest . mock ( "@vue/component-compiler-utils" , ( ) => {
180- throw new Error ( ) ;
182+ const error = new Error ( )
183+ error . code = 'MODULE_NOT_FOUND'
184+ throw error
181185 } ) ;
182186 expect ( ( ) => {
183187 load ( markdownWithFrontmatter , contextEnablingVueRenderFunctions ( ) ) ;
184- } ) . toThrow ( ) ;
188+ } ) . toThrow ( / F a i l e d t o i m p o r t / ) ;
189+ } ) ;
190+
191+ it ( "throw if unintentional exception by importing @vue/component-compiler-utils" , ( ) => {
192+ jest . mock ( "@vue/component-compiler-utils" , ( ) => {
193+ throw new Error ( 'unintentional problem' )
194+ } ) ;
195+ expect ( ( ) => {
196+ load ( markdownWithFrontmatter , contextEnablingVueRenderFunctions ( ) ) ;
197+ } ) . toThrow ( 'unintentional problem' ) ;
185198 } ) ;
186199 } ) ;
187200
@@ -243,20 +256,33 @@ describe("frontmatter-markdown-loader", () => {
243256
244257 it ( "throw if vue-template|compiler is not installed in the project" , ( ) => {
245258 jest . mock ( 'vue-template-compiler' , ( ) => {
246- throw new Error ( ) ;
259+ const error = new Error ( )
260+ error . code = 'MODULE_NOT_FOUND'
261+ throw error
247262 } ) ;
248263 expect ( ( ) => {
249264 load ( markdownWithFrontmatterIncludingChildComponent , contextEnablingVueComponent ( ) ) ;
250- } ) . toThrow ( ) ;
265+ } ) . toThrow ( / F a i l e d t o i m p o r t / ) ;
251266 } ) ;
252267
253268 it ( "throw if @vue/component-compiler-utils is not installed in the project" , ( ) => {
254269 jest . mock ( "@vue/component-compiler-utils" , ( ) => {
255- throw new Error ( ) ;
270+ const error = new Error ( )
271+ error . code = 'MODULE_NOT_FOUND'
272+ throw error
273+ } ) ;
274+ expect ( ( ) => {
275+ load ( markdownWithFrontmatterIncludingChildComponent , contextEnablingVueComponent ( ) ) ;
276+ } ) . toThrow ( / F a i l e d t o i m p o r t / ) ;
277+ } ) ;
278+
279+ it ( "throw if unintentional exception by importing @vue/component-compiler-utils" , ( ) => {
280+ jest . mock ( "@vue/component-compiler-utils" , ( ) => {
281+ throw new Error ( 'unintentional problem' )
256282 } ) ;
257283 expect ( ( ) => {
258284 load ( markdownWithFrontmatterIncludingChildComponent , contextEnablingVueComponent ( ) ) ;
259- } ) . toThrow ( ) ;
285+ } ) . toThrow ( 'unintentional problem' ) ;
260286 } ) ;
261287 } ) ;
262288
0 commit comments