问题
I am fighting with this strange error when running unit tests for my application.
zone.js:260 Uncaught [object Object] thrown
Zone.runTask @ zone.js:260
ZoneTask.invoke @ zone.js:423
I dont know which test is failing cause the console only drop that error. It is not hapenning in my local, where the tests run whithout any problem.
Before that error i was suffering the "Script error" error but I solved it with the --disable-web-security flag for ChromeHeadless. I dont know if it has something to do with this new error.
Both my locale en the remote are linux.
回答1:
You might have different versions of modules installed on the remote, or different versions of global npm packages. Any mismatched version of dependency can yield a different result on either machine.
Purge your npm cache on both machines:
npm cache clean
Reinstall your node_modules
on both machines:
rm -fr node_modules
npm install
Verify the local npm packages are the same on each machine
npm list --depth=0
Verify global package versions are the same. You can list global packages like this
npm list -g --depth=0
Once you have everything the same. You should see the same result on both machines.
Start by trying to run karma
karma start
If that works, next run each test separately.
karma run -- --grep=search_string
If the error is preventing you from starting karma. Check the startup scripts for tests, and see if you can comment out modules from your Angular app. Keep reducing the dependencies until you get Karma running. Reintroduce the dependencies slowly until you find the offender.
来源:https://stackoverflow.com/questions/47873996/uncaught-object-object-when-running-karma-tests-on-angular