简体   繁体   中英

wierd error when running unit test with ionic 2

I'm building an ionic 2 application with karma and jasmine for unit testing and suddenly I get this error when running my unit tests.

Does someone know where the problem is and what the problem is?

Martijn

ERROR: 'Unhandled Promise rejection:', 'null is not an object (evaluating 'link.match')', '; Zone:', '<root>', '; Task:', 'Promise.then', '; Value:', TypeError{stack: 'setLink@http://localhost:9876/absolute/var/folders/0h/gf8s5_tj7x7f953vj4yhyp5h0000gp/T/c2e92d78eba2d7ff1999b961b1eb626b.browserify?fa64c4575df6c4e0f466062ff4330eb717508bdc:987:6033
http://localhost:9876/absolute/var/folders/0h/gf8s5_tj7x7f953vj4yhyp5h0000gp/T/c2e92d78eba2d7ff1999b961b1eb626b.browserify?fa64c4575df6c4e0f466062ff4330eb717508bdc:987:3252
invoke@http://localhost:9876/base/node_modules/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:323:34
run@http://localhost:9876/base/node_modules/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:216:50
http://localhost:9876/base/node_modules/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:571:61
invokeTask@http://localhost:9876/base/node_modules/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:356:43
runTask@http://localhost:9876/base/node_modules/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:256:58
drainMicroTaskQueue@http://localhost:9876/base/node_modules/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:474:43
promiseReactionJob@http://localhost:9876/base/node_modules/es6-shim/es6-shim.js?e7f7126a0be128572b15e7524cb57a8a4d58684e:2194:32
http://localhost:9876/base/node_modules/es6-shim/es6-shim.js?e7f7126a0be128572b15e7524cb57a8a4d58684e:2182:27
handleMessage@http://localhost:9876/base/node_modules/es6-shim/es6-shim.js?e7f7126a0be128572b15e7524cb57a8a4d58684e:2139:15', line: 987, sourceURL: 'http://localhost:9876/absolute/var/folders/0h/gf8s5_tj7x7f953vj4yhyp5h0000gp/T/c2e92d78eba2d7ff1999b961b1eb626b.browserify?fa64c4575df6c4e0f466062ff4330eb717508bdc'}
ERROR: Error{line: 538, sourceURL: 'http://localhost:9876/base/node_modules/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277', stack: 'resolvePromise@http://localhost:9876/base/node_modules/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:538:76
http://localhost:9876/base/node_modules/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:574:32
invokeTask@http://localhost:9876/base/node_modules/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:356:43
runTask@http://localhost:9876/base/node_modules/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:256:58
drainMicroTaskQueue@http://localhost:9876/base/node_modules/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:474:43
promiseReactionJob@http://localhost:9876/base/node_modules/es6-shim/es6-shim.js?e7f7126a0be128572b15e7524cb57a8a4d58684e:2194:32
http://localhost:9876/base/node_modules/es6-shim/es6-shim.js?e7f7126a0be128572b15e7524cb57a8a4d58684e:2182:27
handleMessage@http://localhost:9876/base/node_modules/es6-shim/es6-shim.js?e7f7126a0be128572b15e7524cb57a8a4d58684e:2139:15', rejection: TypeError{stack: 'setLink@http://localhost:9876/absolute/var/folders/0h/gf8s5_tj7x7f953vj4yhyp5h0000gp/T/c2e92d78eba2d7ff1999b961b1eb626b.browserify?fa64c4575df6c4e0f466062ff4330eb717508bdc:987:6033
http://localhost:9876/absolute/var/folders/0h/gf8s5_tj7x7f953vj4yhyp5h0000gp/T/c2e92d78eba2d7ff1999b961b1eb626b.browserify?fa64c4575df6c4e0f466062ff4330eb717508bdc:987:3252
invoke@http://localhost:9876/base/node_modules/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:323:34
run@http://localhost:9876/base/node_modules/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:216:50
http://localhost:9876/base/node_modules/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:571:61
invokeTask@http://localhost:9876/base/node_modules/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:356:43
runTask@http://localhost:9876/base/node_modules/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:256:58
drainMicroTaskQueue@http://localhost:9876/base/node_modules/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:474:43
promiseReactionJob@http://localhost:9876/base/node_modules/es6-shim/es6-shim.js?e7f7126a0be128572b15e7524cb57a8a4d58684e:2194:32
http://localhost:9876/base/node_modules/es6-shim/es6-shim.js?e7f7126a0be128572b15e7524cb57a8a4d58684e:2182:27
handleMessage@http://localhost:9876/base/node_modules/es6-shim/es6-shim.js?e7f7126a0be128572b15e7524cb57a8a4d58684e:2139:15', line: 987, sourceURL: 'http://localhost:9876/absolute/var/folders/0h/gf8s5_tj7x7f953vj4yhyp5h0000gp/T/c2e92d78eba2d7ff1999b961b1eb626b.browserify?fa64c4575df6c4e0f466062ff4330eb717508bdc'}, promise: ZoneAwarePromise{__zone_symbol__state: 0, __zone_symbol__value: TypeError{stack: ..., line: ..., sourceURL: ...}}, zone: Zone{_properties: Object{}, _parent: null, _name: '<root>', _zoneDelegate: ZoneDelegate{_taskCounts: ..., zone: ..., _parentDelegate: ..., _forkZS: ..., _forkDlgt: ..., _interceptZS: ..., _interceptDlgt: ..., _invokeZS: ..., _invokeDlgt: ..., _handleErrorZS: ..., _handleErrorDlgt: ..., _scheduleTaskZS: ..., _scheduleTaskDlgt: ..., _invokeTaskZS: ..., _invokeTaskDlgt: ..., _cancelTaskZS: ..., _cancelTaskDlgt: ..., _hasTaskZS: ..., _hasTaskDlgt: ...}}, task: ZoneTask{runCount: 1, type: 'microTask', zone: Zone{_properties: ..., _parent: ..., _name: ..., _zoneDelegate: ...}, source: 'Promise.then', data: undefined, scheduleFn: undefined, cancelFn: null, callback: function () { ... }, invoke: function () { ... }}}

The problem is that I used localStorage in my unit test. I deleted that and it fixed my problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM