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
+
1
3
// testing i18n component
2
4
// http://kazupon.github.io/vue-i18n
3
5
import TranslatedMessage from './TranslatedMessage.vue'
4
6
import VueI18n from 'vue-i18n'
5
7
import { mountCallback } from 'cypress-vue-unit-test'
6
8
7
- /* eslint-env mocha */
8
9
// https://github.com/bahmutov/cypress-vue-unit-test/issues/332
9
10
describe . skip ( 'VueI18n' , ( ) => {
10
11
// need to use VueI18n as a plugin
Original file line number Diff line number Diff line change @@ -286,6 +286,20 @@ interface MountOptions {
286
286
*/
287
287
type MountOptionsArgument = Partial < ComponentOptions & MountOptions >
288
288
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
+
289
303
/**
290
304
* Mounts a Vue component inside Cypress browser.
291
305
* @param {object } component imported from Vue file
@@ -351,6 +365,8 @@ export const mount = (
351
365
. then ( ( win ) => {
352
366
// @ts -ignore
353
367
win . Vue = Vue
368
+ // @ts -ignore
369
+ win . Vue . config . errorHandler = failTestOnVueError
354
370
355
371
// @ts -ignore
356
372
const document : Document = cy . state ( 'document' )
You can’t perform that action at this time.
0 commit comments