使用离子2运行单元测试时出现错误的错误

时间:2016-05-26 07:55:17

标签: unit-testing jasmine karma-runner ionic2 zonejs

我正在构建一个带有karma和jasmine的离子2应用程序进行单元测试,突然间我在运行单元测试时遇到此错误。

有人知道问题出在哪里以及问题是什么吗?

马亭

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 () { ... }}}

1 个答案:

答案 0 :(得分:0)

问题是我在单元测试中使用了localStorage。我删除了它,它解决了我的问题。