Skip to content

Commit 00c137f

Browse files
committed
test: check unexpected warnings
1 parent 3cfd843 commit 00c137f

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

test/helpers/to-have-been-warned.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ if (typeof console === 'undefined') {
55
}
66
}
77

8+
let asserted
89
function hasWarned (msg) {
910
var count = console.error.calls.count()
1011
var args
@@ -23,11 +24,13 @@ function hasWarned (msg) {
2324

2425
// define custom matcher for warnings
2526
beforeEach(() => {
27+
asserted = []
2628
spyOn(console, 'error')
2729
jasmine.addMatchers({
2830
toHaveBeenWarned: () => {
2931
return {
3032
compare: msg => {
33+
asserted = asserted.concat(msg)
3134
var warned = Array.isArray(msg)
3235
? msg.some(hasWarned)
3336
: hasWarned(msg)
@@ -42,3 +45,17 @@ beforeEach(() => {
4245
}
4346
})
4447
})
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+
})

test/helpers/wait-for-update.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ window.waitForUpdate = initialCb => {
4040

4141
Vue.nextTick(() => {
4242
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)')
4444
}
4545
shift()
4646
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy