File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ if (typeof console === 'undefined') {
5
5
}
6
6
}
7
7
8
+ let asserted
8
9
function hasWarned ( msg ) {
9
10
var count = console . error . calls . count ( )
10
11
var args
@@ -23,11 +24,13 @@ function hasWarned (msg) {
23
24
24
25
// define custom matcher for warnings
25
26
beforeEach ( ( ) => {
27
+ asserted = [ ]
26
28
spyOn ( console , 'error' )
27
29
jasmine . addMatchers ( {
28
30
toHaveBeenWarned : ( ) => {
29
31
return {
30
32
compare : msg => {
33
+ asserted = asserted . concat ( msg )
31
34
var warned = Array . isArray ( msg )
32
35
? msg . some ( hasWarned )
33
36
: hasWarned ( msg )
@@ -42,3 +45,17 @@ beforeEach(() => {
42
45
}
43
46
} )
44
47
} )
48
+
49
+ afterEach ( done => {
50
+ const warned = msg => asserted . some ( assertedMsg => msg . indexOf ( assertedMsg ) > - 1 )
51
+ let count = console . error . calls . count ( )
52
+ let args
53
+ while ( count -- ) {
54
+ args = console . error . calls . argsFor ( count )
55
+ if ( ! warned ( args [ 0 ] ) ) {
56
+ done . fail ( `Unexpected console.error message: ${ args [ 0 ] } ` )
57
+ return
58
+ }
59
+ }
60
+ done ( )
61
+ } )
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ window.waitForUpdate = initialCb => {
40
40
41
41
Vue . nextTick ( ( ) => {
42
42
if ( ! queue . length || ! queue [ queue . length - 1 ] . fail ) {
43
- console . warn ( 'waitForUpdate chain is missing .then(done)' )
43
+ throw new Error ( 'waitForUpdate chain is missing .then(done)' )
44
44
}
45
45
shift ( )
46
46
} )
You can’t perform that action at this time.
0 commit comments