TypeError: expect(...).toBeObservable is not a function - Jasmine marbles - angular7

I am trying to write a basic ngrx effects testing. However I keep getting the error as TypeError: expect(...).toBeObservable is not a function.
This is a new project setup with Angular 7. I had no issues with my previous projects which ran in angular 4.
Initially thought it could be something to do with packages so upgraded all packages to the most latest but no luck yet.
I event tried to test a very simple observable as expect(effects.test$).toBeObservable(5); but it gives the same error. As mentioned in the title I am using jasmine-marbles and the version is 0.4.1.

You need to init the test scheduler and add matchers in before each or toBeObservable will not be defined:
import { addMatchers, initTestScheduler } from 'jasmine-marbles';
beforeEach(() => {
...
initTestScheduler();
addMatchers();
});

Related

CableReady (Rails) Basic case giving mystifying error message

cable_ready 4.5.0
rails 6.1.4.1
ruby 3.0.2p107
This is a simple example from the basic tutorial (https://www.youtube.com/watch?v=F5hA79vKE_E) I suspect the error I am getting is because either cable_ready or rails evolved a little and created a tiny incompatibility.
I get this error in the JS console:
It is triggered when in my controller I ask cable ready to:
cable_ready["timeline"].console_log(message: "***** cable ready post created")
Which leads to my timeline_channel to:
received(data) {
console.log("******** Received data:", data.operations)
if (data.cableReady) CableReady.perform(data.operations)
}
My interpretation is perform causes this line in cable_ready.js line 13:
operations.forEach(function (operation) {
if (!!operation.batch) batches[operation.batch] = batches[operation.batch] ? ++batches[operation.batch] : 1;
});
Is finding something in the received data that it doesn't like.
That's where my trail ends. Can someone see what I am doing wrong, or tell me what other code you'd like me to include?
Solution: downgrade the version of the cable_ready javascript library.
I previously (maybe a year ago) did this tutorial using CableReady 4.5, Ruby 2.6.5 and Rails 6.0.4 and it worked like a charm back then as well as today.
But today, I tried this tutorial again on a duplicate project--same versions of CR, Ruby, and Rails and now I get java console errors similar to yours.
TypeError: undefined is not a function (near '...operations.forEach...')
perform -- cable_ready.js:13
received -- progress_bar_channel.js:8
I looked at the output of yarn list and saw that cable_ready was version 5.0.0-pre8 on the bad project and it was 5.0.0-pre1 on the good project. The downgrade could be accomplished with yarn add cable_ready#^5.0.0-pre1 in the bad project folder and now both projects work.
FYI for other newbies like me trying to understand how CableReady works: This tutorial gives another example of CableReady, and was also fixed the same way.

MockWebServer: java.lang.NoSuchMethodError

Trying MockWebServer for the first time on a Groovy/Spring project that uses Spock for unit testing.
I added MockWebServer dependencies as directed (I had to add the second line myself to avoid errors, but it's not documented:
testImplementation("com.squareup.okhttp3:mockwebserver:4.0.0")
testImplementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.40")
I have a basic Spock test that looks like this:
def 'server'() {
setup:
MockWebServer server = new MockWebServer()
expect:
server
}
But it fails with this output:
java.lang.NoSuchMethodError: okhttp3.internal.Util.immutableListOf([Ljava/lang/Object;)Ljava/util/List;
at okhttp3.mockwebserver.MockWebServer.<init>(MockWebServer.kt:176)
Is there another dependency I'm missing? Does MockWebServer not play well with Groovy and Spock?
For what it's worth, using version 3.1.4 seems to work:
testImplementation("com.squareup.okhttp3:mockwebserver:3.14.2")
(I'm a first time user of MockWebServer)
Thank you!
Try adding this:
testImplementation("com.squareup.okhttp3:mockwebserver:4.0.0")
testImplementation("com.squareup.okhttp3:okhttp:4.0.0")
With MockWebServer your OkHttp dependency must be the same version.
I got the same problem, I found the solution in version, just change the version to "3.7.0" and it's work fine.
there is some discussion about version changing to "3.4.1" but this version got the problem (Cannot inherit from final class) that discussed at this issue :
https://github.com/andrzejchm/RESTMock/issues/56
so the safest version is "3.7.0" :D
just notice that both versions should be the same..
change your to dependencies to below:
//mock retrofit
testImplementation("com.squareup.okhttp3:mockwebserver:3.7.0")
testImplementation("com.squareup.okhttp3:okhttp:3.7.0")
//if your source code is java
testImplementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.40")

weird import issues - Jung2

I've been trying to get Jung 2.1.1 to work successfully but whatever breaking changes were made are just not making sense.
After importing the 2.1.1 jars, I get the error:
The constructor VisualizationViewer(Network, LayoutAlgorithm, Dimension) is undefined
for the line:
VisualizationViewer vv = new
VisualizationViewer(g, layoutAlgorithm, new Dimension(900, 900));
where
Network g = NetworkBuilder.undirected().build(); // and other load steps
There are other imports that aren't working, like
import edu.uci.ics.jung.visualization.decorators.PickableNodePaintFunction;
import edu.uci.ics.jung.visualization.layout.LayoutAlgorithmTransition;
Edit: It appears the classes in the Jung 2.1.1 JAR still use the old definitions, for example
VisualizationViewer(Layout<V,E>,Dimension)
and not
VisualizationViewer(Network<N,E>,Dimension,Dimension)
This question was answered in https://github.com/jrtom/jung/issues/201
The short version is that you should not be cloning the HEAD version on the JUNG website; that's the 3.0 version in development, which is not yet ready for release, and is incompatible with 2.1.1. Use the 2.1.1 version explicitly for both the jars and the samples.

Dart Polymer : Type X is not a subtype of type Y

I develop my application with Dart and Polymer on PyCharm. I currently have an error :
Exception: type 'ObservableList<DrugFilterItem>' is not a subtype of type 'ObservableList<DrugCompareItem>' of '__$orderFilterList#51385934'
ObservableList is from package:observe/src/observable_list.dart
DrugFilterItem is from package:synmed/drug_elements/views/drug_filter_menu.dart
ObservableList is from package:observe/src/observable_list.dart
DrugCompareItem is from package:synmed/drug_elements/views/drug_search_toolbar.dart
DrugFilterItem and DrugCompareItem are both custom classes, DrugCompareItem extends DrugFilterItem, and the line designed by the error is :
ObservableList<DrugCompareItem> orderFilterList = new ObservableList<DrugFilterItem>();
The problem suddenly happened today : I installed Pycharm 2016.3 and tried to code, but I had an error with the package shadow, which I solved. Since, I have this error which I supposed came from a problem with the packages as the code didn't change from before to after.
What I have found for now is nothing in fact, I read a lot of post on this kind of error, one of the recurrent subject was the imports but I didn't find any problem with this. I am using Dart 1.20.1 and
polymer: "<=0.16.4+1"
core_elements: "<=0.7.1+3"
paper_elements: "<=0.7.1"
Do anyone has any clue for me? Thanks!
Sounds like https://github.com/dart-lang/sdk/issues/14972#issuecomment-108402835
I believe this is working as intended. A List is not assignable to a List, even if it only contains Apples.
There are several ways to work around this:
iterable.map((x) => x) (removing the generic type),
new List<MethodMirror>.from(iterable)
new MyIterableWrapper<MethodMirror>(iterable) (where the iterable-wrapper that would need to be written).

AngularJS with .NET MVC Bundling Minification Error

I have been developing a large AngularJS application inside of a .NET MVC Website. I've gone way to long without testing if it will sucesfully minifiy using the Bundle Optimiazation Features?
BundleTable.EnableOptimizations = True
And of Course, it fails. I've been playing with the Order I bundle my scripts, and ensuring I am using String Literals for my Controller Names (I wasn't, and that is a lot of re-factoring that I will have to do).
But I can not get my Core Scripts to Minifiy without the angular "Unknown Provider" error.
Here is the exact Error:
Uncaught Error: [$injector:modulerr] [http://errors.angularjs.org/1.3.14/$injector/modulerr?p0=ppAccount&p1=Error…redScripts%3Fv%3DknV3wkCOg32ajaw4GwiRSrTXdo8Ue7MRIn65CPYa1b81%3A1%3A379851)]1
Here is my bundle config that is failing:
bundles.Add(new ScriptBundle("~/bundles/PilotPartnerRequiredScripts")
.Include(
"~/UI/js/jquery/jquery-2.1.3.js",
"~/UI/js/plugins/jquery-ui/jquery-ui.js",
"~/UI/js/bootstrap/bootstrap.js",
"~/UI/js/plugins/pace/pace.min.js",
"~/UI/js/plugins/slimscroll/jquery.slimscroll.js",
"~/UI/js/inspinia.js",
"~/UI/js/angular/angular.js",
"~/UI/js/ui-router/angular-ui-router.js",
"~/UI/js/bootstrap/ui-bootstrap-tpls-0.12.1.js",
"~/UI/js/angular/angular-resource.js",
"~/UI/js/angular/angular-sanitize.js",
"~/UI/js/angular/angular-route.js",
"~/UI/js/plugins/switchery/switchery.js",
"~/UI/js/plugins/angular-ui-switch/angular-ui-switch.js",
"~/UI/js/plugins/angularLocalStorage/angular-local-storage.js",
"~/UI/js/plugins/ngDialog/ngDialog.js",
"~/Scripts/ngTags/ng-tags-input.js",
"~/Scripts/uiSortable/sortable.js",
"~/Scripts/kendo/2014.3.1119/kendo.all.min.js",
"~/Scripts/xeditable/xeditable.js"
For the life of me, I can't figure out which dependency isn't being resolved. I feel that if I can narrow it down to a specific dependency I know I can solve the issue.
Is there any way to track down the specific Module that is causing the issue?
Any suggestions on how to make this work?
Thank you for your help.
You should always follow strict di while injecting dependency (Array notation)
Angualar Doc has mentioned that, Do follow strict DI while doing minification, otherwise it could break you app
Eg.(Code)
angular.module('myModule', [])
.factory('serviceId', ['depService', function(depService) {
// ...
}])
.directive('directiveName', ['depService', function(depService) {
// ...
}])
.filter('filterName', ['depService', function(depService) {
// ...
}]);
In above snippet I followed inline array notation of DI, it has been applied on various angular component just to demonstrate it. You should make sure that you follow it wherever you're injecting dependency.

Resources