I have the following problem:
When I run unit/integration tests for my Angular project with Karma, there is like a 50:50 chance that my tests will succeed/fail. Mostly it works on my maschine (:D), but not on our build server and that makes it really unreliable at all.
When it fails, it is always a cryptic error message, which says
script error.
...nothing more. Now the strange thing about it is, that it is always another test which fails.
Here is what I already did or had a look at:
https://github.com/karma-runner/karma/issues/1268
https://github.com/karma-runner/karma/issues/543
I do not have circular dependencies (at least ng build/serve doesn't complain about it)
I figured out, that It could be linked to a cross-origin-policy violation, but I actually don't trigger XHR's or lazy load other stuff (at least I think so)
These are my dependencies:
"dependencies": {
"#angular/animations": "^6.0.9",
"#angular/cdk": "^6.4.0",
"#angular/common": "^6.0.9",
"#angular/compiler": "^6.0.9",
"#angular/core": "^6.0.9",
"#angular/flex-layout": "^6.0.0-beta.16",
"#angular/forms": "^6.0.9",
"#angular/http": "^6.0.9",
"#angular/material": "^6.4.0",
"#angular/platform-browser": "^6.0.9",
"#angular/platform-browser-dynamic": "^6.0.9",
"#angular/platform-server": "^6.0.9",
"#angular/router": "^6.0.9",
"#ngrx/effects": "^6.0.1",
"#ngrx/router-store": "^6.0.1",
"#ngrx/store": "^6.0.1",
"#ngrx/store-devtools": "^6.0.1",
"core-js": "^2.5.7",
"devextreme": "^18.1.4",
"devextreme-angular": "^18.1.4",
"i": "^0.3.6",
"jquery": "^3.3.1",
"ngx-scrollbar": "^2.1.0",
"node-sass": "^4.9.0",
"npm": "^6.2.0",
"rxjs": "^6.2.2",
"stream": "0.0.2",
"web-animations-js": "^2.3.1",
"zone.js": "^0.8.26"
},
"devDependencies": {
"#angular-devkit/build-angular": "~0.6.3",
"#angular/cli": "^6.0.8",
"#angular/compiler-cli": "^6.0.9",
"#angular/language-service": "^6.0.9",
"#types/jasmine": "^2.8.8",
"#types/jasminewd2": "^2.0.3",
"#types/node": "^10.5.2",
"codelyzer": "^4.4.2",
"fs-extra": "^6.0.1",
"git-describe": "^4.0.3",
"gulp": "^4.0.0",
"gulp-param": "^1.0.3",
"gulp-run": "^1.7.1",
"hogan.js": "^3.0.2",
"husky": "^0.14.3",
"jasmine-core": "^3.1.0",
"jasmine-spec-reporter": "^4.2.1",
"jszip": "^3.1.5",
"karma": "^2.0.4",
"karma-chrome-launcher": "~2.2.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^2.0.1",
"karma-jasmine": "^1.1.2",
"karma-jasmine-html-reporter": "^1.2.0",
"license-checker": "^20.1.0",
"lint-staged": "^7.2.0",
"markdown-include": "^0.4.3",
"prettier": "^1.13.7",
"protractor": "^5.3.2",
"readline-sync": "^1.4.9",
"run-sequence": "^2.2.1",
"stylelint": "^9.3.0",
"stylelint-config-recommended-scss": "^3.2.0",
"stylelint-config-standard": "^18.2.0",
"stylelint-scss": "^3.1.3",
"ts-node": "^6.2.0",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.13.0",
"typescript": "2.7.2",
"yargs": "^11.1.0"
}
What should I do next ??
I appreciate every hint...thanks
From my experience, many times such random errors are due to a dirty state one of the test left behind which in turn fails some other test.
AFAIK the default order for Karma is not expected or defined.
I would try to comment out (binary search style) the first half of the tests and see if it passes consistently.
I finally fixed the issue.
I somehow came on the right track and figured out, which test fails or rather is causing other tests to fail.
// causing part in the tests
beforeEach(() => {
fixture = TestBed.createComponent(FilterSidebarComponent);
component = fixture.componentInstance;
component.data = {} as DataClass;
fixture.detectChanges();
});
The problem was now, that inside a subscription in the component, I call a specific method of the class DataClass:
this.attributeXY.subscribe(event => {
this.data.reset(); <-- reset() was undefined
if (event) {
// do something
...
}
})
The remaining question now is, why the cast of the empty object didn't work in this case?
My expectation was, that the method reset()would be inferred as well
Related
When i try to 'ionic cordova --prod build android', i have this error :
Error: Cannot read property 'getBufferedLength' of undefined
ANDROID_HOME=/usr/local/Caskroom/android-sdk/4333796 (DEPRECATED)
Failed to run "javac -version", make sure that you have a JDK version 8 installed.
You can get it from the following location:
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Your JAVA_HOME is invalid: /Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home
Error: Cannot read property 'getBufferedLength' of undefined
[ERROR] An error occurred while running subprocess cordova.
What is strange is that when i enter 'javac -version' the output is :
macbook$ javac -version
javac 1.8.0_261
also, 'ionic cordova requirements' crash :
> cordova requirements
Error: Cannot read property 'getBufferedLength' of undefined
My package.json :
"dependencies": {
"#angular/common": "^7.2.16",
"#angular/core": "^7.2.16",
"#angular/forms": "^7.2.16",
"#angular/http": "^7.2.16",
"#angular/platform-browser": "^7.2.16",
"#angular/platform-browser-dynamic": "^7.2.16",
"#angular/router": "^7.2.16",
"#ionic-native/card-io": "^5.30.0",
"#ionic-native/core": "^5.30.0",
"#ionic-native/facebook": "^5.30.0",
"#ionic-native/fcm": "^5.30.0",
"#ionic-native/firebase": "^5.30.0",
"#ionic-native/qr-scanner": "^5.30.0",
"#ionic-native/splash-screen": "^5.30.0",
"#ionic-native/status-bar": "^5.30.0",
"#ionic-native/stripe": "^5.30.0",
"#ionic/angular": "^4.11.13",
"card.io.cordova.mobilesdk": "2.1.0",
"cordova-browser": "^6.0.0",
"cordova-ios": "5.0.1",
"cordova-plugin-add-swift-support": "2.0.2",
"cordova-plugin-facebook4": "1.7.4",
"cordova-plugin-fcm-with-dependecy-updated": "^3.2.0",
"cordova-plugin-qrscanner": "3.0.1",
"cordova-plugin-stripe": "1.5.3",
"cordova-support-android-plugin": "1.0.1",
"cordova-support-google-services": "1.3.2",
"core-js": "^2.6.12",
"firebase": "7.17.1",
"node-sass": "^4.12.0",
"nodemailer": "^6.4.16",
"rxjs": "^6.6.3",
"tslib": "^1.14.1",
"zone.js": "~0.8.29"
},
"devDependencies": {
"#angular-devkit/architect": "~0.13.8",
"#angular-devkit/build-angular": "~0.13.8",
"#angular-devkit/core": "~7.3.8",
"#angular-devkit/schematics": "~7.3.8",
"#angular/cli": "7.3.9",
"#angular/compiler": "^7.2.16",
"#angular/compiler-cli": "^7.2.16",
"#angular/language-service": "^7.2.16",
"#ionic/angular-toolkit": "~1.5.1",
"#types/jasmine": "~2.8.8",
"#types/jasminewd2": "^2.0.8",
"#types/node": "~12.0.0",
"codelyzer": "~4.5.0",
"cordova-android": "9.0.0",
"cordova-plugin-device": "^2.0.3",
"cordova-plugin-ionic-keyboard": "^2.2.0",
"cordova-plugin-ionic-webview": "^4.1.3",
"cordova-plugin-splashscreen": "^5.0.3",
"cordova-plugin-statusbar": "^2.4.3",
"cordova-plugin-whitelist": "^1.3.4",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^5.2.3",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.6",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^7.0.0",
"ts-node": "~8.3.0",
"tslint": "~5.17.0",
"typescript": "~3.1.6"
}
I have spend several hours trying to fix that problem to build my application with no success. Any help would be greatly appreciated !
So after some research, I found the problem. I was trying to use the Barcode scanner along with the QR code scanner from Ionic modules. Those are not compatible.
What i did was remove the Barcode scanner and implement this pull request to my QR code module in order to be able to use Barcode with the QR code module :
pull request in QR code module to support barcode
At the end of the day everything worked fine.
For Orbitdb to work with IPFS, perhaps there are some extra dependencies which are not mentioned anywhere specifically. I tried creating a simple key-value db referring from the docs:
orbit.js
const IPFS = require("ipfs");
const OrbitDB = require("orbit-db");
const ipfsOptions = {
EXPERIMENTAL: {
pubsub: true
}
};
const ipfs = await IPFS.create(ipfsOptions);
const orbitdb = await OrbitDB.createInstance(ipfs);
const db = await orbitdb.create("test", "keyvalue", {
overwrite: true,
replicate: true,
accessController: {
type: "ipfs",
admin: ["*"],
write: ["*"]
}
});
await db.set("hello", "world");
console.log(db.all);
I had the following dependencies in my package.json:
"dependencies": {
"ipfs": "^0.46.0",
"orbit-db": "^0.24.1"
}
It threw the following error:
Trace: Error: Could not append entry, key "..." is not allowed to write to the log
I tried resolving it but nothing seemed to work. Now, comes the interesting part. So, I am currently developing the frontend part of the code that will use Orbitdb. Out of sheer luck (curiosity), I copy pasted the file orbit.js to the root folder containing the frontend code. Running the same file there, worked perfectly, creating the db successfully! Here are all the dependencies and dev-dependencies in the package.json for the frontend code (which is in Angular):
"dependencies": {
"#akveo/ng2-completer": "^9.0.1",
"#angular/animations": "^9.0.4",
"#angular/cdk": "^9.1.2",
"#angular/common": "^9.0.4",
"#angular/compiler": "^9.0.4",
"#angular/core": "^9.0.4",
"#angular/forms": "^9.0.4",
"#angular/google-maps": "^9.1.0",
"#angular/material": "^9.1.0",
"#angular/platform-browser": "^9.0.4",
"#angular/platform-browser-dynamic": "^9.0.4",
"#angular/router": "^9.0.4",
"#asymmetrik/ngx-leaflet": "3.0.1",
"#nebular/auth": "5.0.0",
"#nebular/eva-icons": "5.0.0",
"#nebular/security": "5.0.0",
"#nebular/theme": "5.0.0",
"#swimlane/ngx-charts": "^13.0.2",
"angular2-chartjs": "0.4.1",
"bootstrap": "4.3.1",
"chart.js": "^2.9.3",
"ckeditor": "4.7.3",
"classlist.js": "1.1.20150312",
"core-js": "2.5.1",
"env-paths": "^2.2.0",
"eva-icons": "^1.1.3",
"intl": "1.2.5",
"ionicons": "2.0.1",
"ipfs": "^0.46.0",
"it-all": "^1.0.2",
"leaflet": "1.2.0",
"metamask-logo": "^2.2.1",
"nebular-icons": "1.1.0",
"nedb": "^1.8.0",
"ng2-ckeditor": "^1.2.2",
"ng2-smart-table": "^1.6.0",
"node-sass": "^4.14.1",
"normalize.css": "6.0.0",
"orbit-db": "^0.24.1",
"pace-js": "1.0.2",
"roboto-fontface": "0.8.0",
"rxjs": "6.5.4",
"rxjs-compat": "6.3.0",
"socicon": "3.0.5",
"style-loader": "^1.1.3",
"test-ipfs-example": "^2.0.3",
"tinymce": "4.5.7",
"tslib": "^1.10.0",
"typeface-exo": "0.0.22",
"web-animations-js": "^2.3.2",
"web3": "^1.2.9",
"zone.js": "~0.10.2"
},
"devDependencies": {
"#angular-devkit/build-angular": "^0.901.7",
"#angular/cli": "^9.0.4",
"#angular/compiler-cli": "^9.0.4",
"#angular/language-service": "9.0.4",
"#compodoc/compodoc": "^1.1.11",
"#fortawesome/fontawesome-free": "^5.2.0",
"#types/d3-color": "1.0.5",
"#types/googlemaps": "^3.39.3",
"#types/jasmine": "2.5.54",
"#types/jasminewd2": "2.0.3",
"#types/leaflet": "1.2.3",
"#types/node": "^12.11.1",
"codelyzer": "^5.1.2",
"conventional-changelog-cli": "1.3.4",
"husky": "0.13.3",
"jasmine-core": "2.6.4",
"jasmine-spec-reporter": "4.1.1",
"karma": "1.7.1",
"karma-chrome-launcher": "2.1.1",
"karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "1.3.0",
"karma-jasmine": "1.1.0",
"karma-jasmine-html-reporter": "0.2.2",
"npm-run-all": "4.0.2",
"protractor": "5.1.2",
"rimraf": "2.6.1",
"stylelint": "7.13.0",
"ts-node": "3.2.2",
"tslint": "^5.7.0",
"tslint-language-service": "^0.9.9",
"typescript": "3.7.5"
}
I know most of these dependencies don't even relate to Orbitdb, I can definitely narrow them down to particular dependencies but can someone throw some light onto why it worked here. I'm totally new to using Orbitdb.
OrbitDB already handle its dependencies correctly
Your code should work and you can even simplify it
const start = async () => {
const ipfs = await IPFS.create();
const orbitdb = await OrbitDB.createInstance(ipfs);
const db = await orbitdb.create("test", "keyvalue", {
overwrite: true,
replicate: true,
accessController: {
write: ["*"],
},
});
await db.set("hello", "world");
console.log(db.all);
db.close();
ipfs.stop();
};
start();
i try to run my react native app to ios but i got this error, while in android the app work just fine, do someone know about this ?
xcode 11.5,
rn 0.61.5,
using react native cli
i already search on several site but dont seem find any solution, here the screen shoot :
"dependencies": {
"#microsoft/signalr": "^3.1.3",
"#react-native-community/async-storage": "^1.7.1",
"#react-native-community/datetimepicker": "^2.2.1",
"#react-native-community/masked-view": "0.1.5",
"#react-native-community/picker": "^1.6.1",
"#react-native-community/viewpager": "3.3.0",
"#sentry/react-native": "^1.4.1",
"axios": "^0.19.1",
"color": "^3.1.2",
"ellipsize": "^0.1.0",
"form-data": "^3.0.0",
"google-translate": "^3.0.0",
"i18n-js": "^3.5.1",
"intl": "^1.2.5",
"moment": "^2.24.0",
"moment-range": "^4.0.2",
"numeral": "^2.0.6",
"opentok-react-native": "^0.12.2",
"react": "16.9.0",
"react-cookies": "^0.1.1",
"react-native": "0.61.5",
"react-native-amazing-cropper": "^0.1.1",
"react-native-biometrics": "^2.1.4",
"react-native-camera": "^3.17.0",
"react-native-collapsible": "^1.5.1",
"react-native-daterange-picker": "^1.1.3",
"react-native-device-info": "^5.5.3",
"react-native-file-picker": "0.0.19",
"react-native-geocoder": "^0.5.0",
"react-native-gesture-handler": "^1.5.3",
"react-native-image-crop-tools": "^1.3.4",
"react-native-image-picker": "^2.3.0",
"react-native-localize": "^1.4.0",
"react-native-location": "^2.5.0",
"react-native-masked-text": "^1.13.0",
"react-native-onesignal": "^3.6.3",
"react-native-overlay-section": "0.1.13",
"react-native-paper": "3.4.0",
"react-native-reanimated": "^1.4.0",
"react-native-responsive-screen": "1.4.0",
"react-native-safe-area-context": "0.6.2",
"react-native-screens": "2.0.0-alpha.22",
"react-native-vector-icons": "^6.6.0",
"react-native-webview": "8.1.1",
"react-navigation": "^4.0.10",
"react-navigation-stack": "^2.0.4",
"react-navigation-tabs": "^2.7.0",
"react-redux": "^7.1.3",
"reanimated-bottom-sheet": "1.0.0-alpha.18",
"redux": "^4.0.5",
"redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0",
"sendbird": "3.0.117",
"styled-components": "^4.4.1",
"throttle-debounce": "^2.1.0",
"validator": "^12.1.0"
},
The error is coming from the react-native-gesture-handler package.
Did you import it in your code ? If yes, try to remove the import and do a rm -rf node_modules && npm install.
If this doesn't work, try to update it (Latest version at the moment is ^1.6.1) in your package.json.
sorry just found the problem, in my app there are custom native library that use scroll view in folder src, that causing register view two times.
I want to update my current project’s angular version to the latest angular version. But facing following error : Overload signatures must all be ambient or non-ambient.
My current angular version is 4.4, as per latest angular version I would like to update to 8.2.
As per https://update.angular.io/ its not recommended to update multiple angular versions at a time so currently I am updating from 4.4 to 5.2 and then would move ahead.
I have followed the steps from https://update.angular.io/#4.4:5.2.
After that I removed/uninstalled 2 Angular2 specific packages as they were not supported in Angular5.
angular2-busy
angular2-uuid
Also I updated few peer dependencies and their respective dev dependencies
#ng-bootstrap/ng-bootstrap
#ngx-translate/core
codelyzer (Updated its dev dependency - tslint)
Now when I try to run “ng serve” command I am getting following errors:
ERROR in /Volumes/Work/Projects/src/app/readiumjs/readium_reader.d.ts (6,18): Overload signatures must all be ambient or non-ambient.
ERROR in /Volumes/Work/Projects/src/app/readiumjs/readium_reader.d.ts (7,18): Overload signatures must all be ambient or non-ambient.
ERROR in /Volumes/Work/Projects/src/lib/epub1.d.ts (14,18): Overload signatures must all be ambient or non-ambient.
Here are my files:
package.json -
"dependencies": {
"#angular/animations": "^5.2.11",
"#angular/common": "^5.2.11",
"#angular/compiler": "^5.2.11",
"#angular/core": "^5.2.11",
"#angular/forms": "^5.2.11",
"#angular/http": "^5.2.11",
"#angular/material": "2.0.0-beta.6",
"#angular/platform-browser": "^5.2.11",
"#angular/platform-browser-dynamic": "^5.2.11",
"#angular/platform-server": "^5.2.11",
"#angular/router": "^5.2.11",
"#ng-bootstrap/ng-bootstrap": "^1.1.1",
"#ngx-translate/core": "^8.0.0",
"#ngx-translate/http-loader": "^2.0.0",
"array-unique": "^0.3.2",
"classlist.js": "^1.1.20150312",
"core-js": "^2.4.1",
"elasticlunr": "^0.9.5",
"enhanced-resolve": "^3.3.0",
"font-awesome": "^4.7.0",
"hammerjs": "^2.0.8",
"intl": "^1.2.5",
"normalizr": "^3.3.0",
"readline": "^1.3.0",
"rxjs": "^5.5.12",
"sw-toolbox": "^3.6.0",
"tether": "^1.4.3",
"ts-helpers": "^1.1.1",
"typescript": "^2.4.2",
"web-animations-js": "2.2.4",
"zone.js": "^0.8.14"
},
"devDependencies": {
"#angular/cli": "1.2.4",
"#angular/compiler-cli": "^5.2.11",
"#compodoc/compodoc": "^1.0.9",
"#types/jasmine": "2.5.38",
"#types/jasminewd2": "~2.0.2",
"#types/node": "~6.0.60",
"bootstrap": "4.0.0-alpha.6",
"codelyzer": "^4.0.1",
"gulp": "^3.9.1",
"gulp-clean": "^0.3.2",
"gulp-concat": "^2.6.1",
"gulp-sync": "^0.1.4",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"jquery": "^3.2.1",
"jquery-ui-dist": "^1.12.1",
"karma": "~1.4.1",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-html-reporter": "^0.2.7",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-phantomjs-launcher": "^1.0.4",
"phantomjs-prebuilt": "^2.1.16",
"protractor": "~5.1.2",
"protractor-html-screenshot-reporter": "0.0.21",
"protractor-jasmine2-screenshot-reporter": "^0.5.0",
"sw-precache": "^5.1.1",
"ts-node": "~3.3.0",
"tslint": "^5.0.0",
"typedoc": "^0.5.7"
}
Below are some parts of the code which I think is failing:
readium_reader.d.ts (6,18) -
declare function setBookTitle(bookId: string, bookTitle: string);
main.js -
function setBookTitle(_bookId, _bookTitle) {
bookId = _bookId;
bookTitle = _bookTitle;
}
epubReadiumReaderComponent.ts -
setBookTitle(bookId, bookName);
Note: I searched for the answer for above issues but couldn’t get any proper solution for it.
Some of them asked to change the function name as its been overloading, but it couldn’t worked for me.
I'm working on Vue.js project, and suddely errors than where errors on console, (console.error) are alerts, (normal browser alerts).
Example. I force this error writing (undefined).anyProperty
console looks:
My package.json modules:
"dependencies": {
"axios": "^0.18.0",
"bootstrap-vue": "^2.0.0-rc.11",
"naranja": "^1.0.2",
"vue": "^2.5.2",
"vue-router": "^3.0.1",
"vuex": "^3.0.1"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^7.1.1",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"chalk": "^2.0.1",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.28.0",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.4",
"friendly-errors-webpack-plugin": "^1.6.1",
"html-webpack-plugin": "^2.30.1",
"node-notifier": "^5.1.2",
"node-sass": "^4.11.0",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"ora": "^1.2.0",
"portfinder": "^1.0.13",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.8",
"postcss-url": "^7.2.1",
"rimraf": "^2.6.0",
"sass-loader": "^7.1.0",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"uglifyjs-webpack-plugin": "^1.1.1",
"url-loader": "^0.5.8",
"vue-loader": "^13.3.0",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.5.2",
"webpack": "^3.6.0",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-dev-server": "^2.9.1",
"webpack-merge": "^4.1.0"
},
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
I cand debug in alerts, because objects are [Object object], thanks for helps.
I don't know anything about Vue, but my recommendation for debugging this would be to replace the window.alert function with you own function containing a debugger
let oldWindowAlert = window.alert;
window.alert = function(){
debugger;
oldWindowAlert.apply(window, arguments);
}
Then, once you catch the debugger, you can investigate the call stack (in Chrome this is very easy) to trace down what function is emitting this alert.
So I did a bit of research for you, but haven't actually tested my hypothesis so take this with a grain of salt...
My gut tells me that somewhere in the code there is an event handler attached to the window error event which alerts the error message and swallows the error. Search the codebase for addEventHandler('error', addEventHandler("error", and onerror, and get rid of it :-)
The docs lead me to believe that Node_Notifier is the culprit. Hard to tell without seeing your code but maybe see what happens if you remove it?