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();
Related
I got the below error when I'm trying to run npm install. Error Message:
taskRepository: Failed to require task module for setTimestamp: require() of ES Module ......\node_modules\dateformat\lib\dateformat.js from .....\setTimestamp.js not
supported.
Instead change the require of dateformat.js in .....\setTimestamp.js to a dynamic import() which is available in all CommonJS modules.
In setTimestamp.js file, we have
const stringReplacer = require("#ui5/builder").processors.stringReplacer;
const df = require("dateformat");
This is a SAPUI5 based cloud application and we've 2 package.json files.
Under Root folder:
"version": "1.2.0",
"devDependencies": {
"#ui5/builder": "^2.11.5",
"#ui5/cli": "^2.14.10",
"#wdio/cli": "7.23.0",
"#wdio/cucumber-framework": "7.23.0",
"#wdio/junit-reporter": "7.23.0",
"#wdio/local-runner": "7.23.0",
"#wdio/selenium-standalone-service": "7.23.0",
"#wdio/spec-reporter": "7.23.0",
"chai": "^4.3.6",
"chromedriver": "^104.0.0",
"cucumber-html-reporter": "5.5.0",
"nyc": "^15.1.0",
"opa-e2e": "^1.0.11",
"request": "^2.88.2",
"request-promise": "^4.2.6",
"shelljs": "^0.8.5",
"type": "module",
"wdio-chromedriver-service": "^7.3.2",
"wdio-cucumber-reporter": "0.0.2",
"wdio-cucumberjs-json-reporter": "^4.4.3"
},
"resolutions": {
"terser": ">=5.14.2",
"markdown-it": ">=12.3.2",
"marked": ">=4.0.10",
"shelljs": ">=0.8.5",
"ejs": ">=3.1.7",
"node-fetch": ">=2.6.7",
"got": ">=11.8.5",
"follow-redirects": ">=1.14.8",
"minimist": ">=1.2.6"
}
Inner one:
"ui5": {
"dependencies": [
"ui5-middleware-livereload",
"ui5-middleware-simpleproxy",
"ui5-middleware-servestatic",
"#dwc/ui5-middleware-dwc"
]
},
"devDependencies": {
"#dwc/ui5-middleware-dwc": "^1.4.2-20220817085704",
"#ui5/cli": "^2.14.10",
"dateformat": "^5.0.3",
"env-cmd": "^10.1.0",
"eslint": "^8.22.0",
"karma": "6.4.0",
"karma-chrome-launcher": "^3.1.1",
"karma-coverage": "^2.2.0",
"karma-junit-reporter": "^2.0.1",
"karma-qunit": "^4.1.2",
"karma-sinon": "^1.0.5",
"karma-ui5": "2.4.0",
"nyc": "^15.1.0",
"qunitjs": "^2.4.1",
"rimraf": "^3.0.2",
"shelljs": "^0.8.5",
"start-server-and-test": "^1.14.0",
"ui5-middleware-livereload": "^0.7.0",
"ui5-middleware-servestatic": "^0.4.0",
"ui5-middleware-simpleproxy": "^0.9.1",
"wdio-chromedriver-service": "7.3.2"
},
"resolutions": {
"terser": ">=5.14.2",
"markdown-it": ">=12.3.2",
"marked": ">=4.0.10",
"ua-parser-js": ">=0.7.24",
"log4js": ">=6.4.0",
"karma": ">=6.3.16",
"follow-redirects": ">=1.14.8",
"minimist": ">=1.2.6"
}
I tried to fix this issue by using:
npm i node-fetch#2.6.1
Or, in package.json file , wrote "type": "module" etc.
Ref: Instead change the require of index.js, to a dynamic import() which is available in all CommonJS modules
Could anyone please help me to solve the error? Any help would be much appreciate.
Request: Please don't close the question. I know it's duplicate question, however I couldn't find any solution, tried how much I found.Thank you
I got the same error requiring node-fetch. The solution was
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
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.
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've set up an Angular development workflow using Docker. However, building the docker and serving the Angular app is a bit slow and takes around ~7 minutes (considering all base images pre-downloaded).
./package.json:
{
"scripts": {
"ng": "ng",
"docker-serve-dev": "docker-compose -f docker-compose.development.yml up --build",
},
"dependencies": {
"#agm/core": "^1.0.0-beta.5",
"#angular/animations": "^7.2.6",
"#angular/cdk": "^7.3.3",
"#angular/common": "^7.2.6",
"#angular/compiler": "^7.2.6",
"#angular/core": "^7.2.6",
"#angular/forms": "^7.2.6",
"#angular/http": "^7.2.6",
"#angular/platform-browser": "^7.2.6",
"#angular/platform-browser-dynamic": "^7.2.6",
"#angular/router": "^7.2.6",
"#asymmetrik/ngx-leaflet": "5.0.1",
"#nebular/auth": "3.3.0",
"#nebular/bootstrap": "3.3.0",
"#nebular/security": "3.3.0",
"#nebular/theme": "3.3.0",
"#ng-bootstrap/ng-bootstrap": "^4.0.4",
"#swimlane/ngx-charts": "^10.1.0",
"angular-tree-component": "8.3.0",
"angular2-chartjs": "0.5.1",
"angular2-toaster": "^7.0.0",
"bootstrap": "4.3.1",
"chart.js": "^2.7.3",
"ckeditor": "4.11.2",
"classlist.js": "1.1.20150312",
"core-js": "2.6.5",
"echarts": "^4.1.0",
"error-stack-parser": "^2.0.2",
"eva-icons": "^1.1.1",
"intl": "1.2.5",
"ionicons": "2.0.1",
"jwt-decode": "^2.2.0",
"leaflet": "1.4.0",
"lodash": "^4.17.11",
"moment": "^2.24.0",
"nebular-icons": "1.1.0",
"ng-snotify": "^4.3.1",
"ng2-ckeditor": "^1.2.2",
"ng2-completer": "2.0.8",
"ng2-slim-loading-bar": "^4.0.0",
"ng2-smart-table": "1.4.0",
"ngx-echarts": "^4.1.0",
"normalize.css": "8.0.1",
"pace-js": "1.0.2",
"primeicons": "^1.0.0",
"primeng": "^7.0.5",
"roboto-fontface": "0.8.0",
"rxjs": "6.4.0",
"rxjs-compat": "6.4.0",
"socicon": "3.0.5",
"stacktrace-gps": "^3.0.2",
"stacktrace-js": "^2.0.0",
"tinymce": "4.5.7",
"tslib": "^1.9.3",
"typeface-exo": "0.0.61",
"web-animations-js": "2.2.5",
"zone.js": "^0.8.29"
},
"devDependencies": {
"#angular-devkit/build-angular": "^0.13.3",
"#angular/cli": "^7.3.3",
"#angular/compiler-cli": "^7.2.6",
"#angular/language-service": "7.2.6",
"#compodoc/compodoc": "^1.1.8",
"#fortawesome/fontawesome-free": "^5.7.2",
"#types/d3-color": "1.2.2",
"#types/googlemaps": "^3.30.16",
"#types/jasmine": "~2.8.8",
"#types/jasminewd2": "~2.0.3",
"#types/leaflet": "1.4.3",
"#types/node": "~8.9.4",
"codelyzer": "^4.5.0",
"conventional-changelog-cli": "2.0.12",
"husky": "1.3.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.1.1",
"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": "^0.2.2",
"npm-run-all": "4.1.5",
"prettier-tslint": "^0.4.2",
"protractor": "~5.4.0",
"rimraf": "^2.6.3",
"stylelint": "9.10.1",
"ts-node": "~7.0.0",
"tslint": "~5.12.1",
"tslint-language-service": "^0.9.9",
"typescript": "~3.1.6"
},
"tasks": [
{
"type": "npm",
"script": "lint",
"problemMatcher": {
"base": "$tslint5",
"fileLocation": "relative"
}
}
]
}
./docker-compose.development.yml:
version: '3.4'
services:
cc-ui-docker-service:
container_name: cc-ui-dev-container
image: cc-ui-dev-dev
build:
context: .
dockerfile: .docker/development.dockerfile
environment:
NODE_ENV: development
volumes:
- './:/usr/share/app'
- /app/node_modules/
ports:
- 4200:80
## set your startup file here
command: ['sh', '-c', 'ng serve --host=0.0.0.0 --watch --poll=2000']
./.docker/development.dockerfile:
FROM node:10.15.1-alpine
# set working directory
RUN mkdir /usr/share/app
WORKDIR /usr/share/app
# add `/usr/share/app/node_modules/.bin` to $PATH
ENV PATH /usr/share/app/node_modules/.bin:$PATH
# install and cache app dependencies
COPY package.json /usr/share/app/package.json
COPY package-lock.json /usr/share/app/package-lock.json
RUN npm install
RUN npm install -g #angular/cli#7.3.3
# add app
COPY . /usr/share/app
EXPOSE 80 443
CMD ["ng", "--host=0.0.0.0","--watch", "--poll=2000", "serve"]
How I can improve the build time?
You can to build an application outside the docker and copy only dist folder into nginx docker image.
After then you don't need to install node_modules evrey time.
Dockerfile example
FROM nginx:latest
ENV TZ=Europe/Moscow
COPY ./dist/my-app /usr/share/nginx/html
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
nginx.conf example
server {
server_name my-app;
root /var/www/frontend/src;
try_files $uri $uri/ index.html;
}
Instead of copying the entire node_modules folder into your container, try to only copy the package.json and after that run ”npm install”. The node_module folder doesn’t have to be copied over to the container since ”npm install” installs all the necessary modules in the container, it reads all dependencies from package.json.
This will reduce building time :)
It's a good practice to use multi-stage builds when building images with Docker.
An example Dockerfile would be:
FROM node:10 as build
WORKDIR /home
COPY package.json package-lock.json .
RUN npm install
COPY . .
RUN npm build # or any other command to package
FROM nginx:alpine
COPY --from=build /home/dist/* /usr/share/nginx/html/
Thats it :)
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