This repository was archived by the owner on Dec 12, 2020. It is now read-only.
  
  
  
  
    
    
    
      
    
  
  
    
File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 1+ /// <reference types="cypress" /> 
2+ 
13// testing i18n component 
24// http://kazupon.github.io/vue-i18n 
35import  TranslatedMessage  from  './TranslatedMessage.vue' 
46import  VueI18n  from  'vue-i18n' 
57import  {  mountCallback  }  from  'cypress-vue-unit-test' 
68
7- /* eslint-env mocha */ 
89// https://github.com/bahmutov/cypress-vue-unit-test/issues/332 
910describe . skip ( 'VueI18n' ,  ( )  =>  { 
1011  // need to use VueI18n as a plugin 
Original file line number Diff line number Diff line change @@ -286,6 +286,20 @@ interface MountOptions {
286286 */ 
287287type  MountOptionsArgument  =  Partial < ComponentOptions  &  MountOptions > 
288288
289+ /** 
290+  * Direct Vue errors to the top error handler 
291+  * where they will fail Cypress test 
292+  * @see  https://vuejs.org/v2/api/#errorHandler 
293+  * @see  https://github.com/cypress-io/cypress/issues/7910 
294+  */ 
295+ function  failTestOnVueError ( err ,  vm ,  info )  { 
296+   console . error ( `Vue error 🔥` ) 
297+   console . error ( err ) 
298+   console . error ( 'component:' ,  vm ) 
299+   console . error ( 'info:' ,  info ) 
300+   window . top . onerror ( err ) 
301+ } 
302+ 
289303/** 
290304 * Mounts a Vue component inside Cypress browser. 
291305 * @param  {object } component imported from Vue file 
@@ -351,6 +365,8 @@ export const mount = (
351365    . then ( ( win )  =>  { 
352366      // @ts -ignore 
353367      win . Vue  =  Vue 
368+       // @ts -ignore 
369+       win . Vue . config . errorHandler  =  failTestOnVueError 
354370
355371      // @ts -ignore 
356372      const  document : Document  =  cy . state ( 'document' ) 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments