How to use webpack.config in karma.conf without duplication - karma-runner

I would like to require the webpack.config in karma.conf to reduce duplication. Somehow it is not working and some errors are being thrown.
Module not found: Error: a dependency to an entry point is not allowed
ERROR [karma]: Uncaught ReferenceError: webpackJsonp is not defined
the way webpack.config is required in karma.conf
var webpackConfig = require('./webpack.config');
webpackConfig.devtool = 'inline-source-map';
webpackConfig.plugins.push(new RewirePlugin());
The entry and output property of the webpack.config are not needed in karma.conf, that might be messing with the setup. How can I get rid of it?
I have tried: webpackConfig.entry = {}; which didn't succeed.
The problem could also be something else?
Would be very nice if you could point to an existing example or correct my mistake!

Related

Virtualized AutoComplete Error - Invalid prop `children` supplied to `ForwardRef(ListboxComponent)`

The Autocomplete Virtualization example at https://mui.com/components/autocomplete/#main-content produces and error in the console advising:
Failed prop type: Invalid prop children supplied to ForwardRef(ListboxComponent), expected a ReactNode.
Does anyone know what the error is referring to? The example works but I'd like to know where the error is coming from to better understand the example 🤓
The error seems to be coming directly from line 109-111 where the the propTypes of children are specifically being defined as node (Typechecking). Because children is not a node, the error is thrown.
ListboxComponent.propTypes = {
children: PropTypes.node,
};
If these lines are commented out, the error goes away; but, are the children supposed to be nodes? It would seem they should be per these lines being added to ensure such but then why is it working without. Does anyone know of any documentation/articles explaining this example in a little more depth?

Meteor error in trying to use collections

I am currently pulling data from collections in the MongoDB but there are 2 in particular that will not work either giving me the following error:
Exception from sub Assets id i574gxNDc9RdHERNn TypeError: Cannot call method 'find' of undefined
Or:
TypeError: Cannot call method 'attachSchema' of undefined
Or:
Object # has no method 'attachSchema'
depending on how I configure it. Does anyone have an idea of what I am doing wrong. I am using the same code for the ones that work as well as the ones that are throwing errors.
The collection looks like this:
Assets = Collections.Assets = Meteor.Assets;
Querying in server/publish.js:
Meteor.publish("Assets", function (){
return Meteor.Assets.find({});
});
Changing it to:
new Mongo.Collection('Assets');
Gives error:
Exception from sub Assets id ZgzZyNYPmMr5gtFGn TypeError: Cannot call method 'find' of undefined
Running the following from the command line in the top (root) directory of the project might fix this (it helped me):
meteor add aldeed:collection2

how to use log4js in test case with karma?

currently I need to add log4js support in my test case, like below:
it(' QuestionController saveQuestion method Testing ', inject(function(localStorageService) {
***var log4js = require('log4js');
var logger = log4js.getLogger();
logger.debug("Some debug messages");***
expect({}).toEqual(localStorageService.get('questionInfoStorage'));
}));
I have tried to include the log4js js and repire js file in karma.conf.js file, it is not working and giving some error like "Module name "events" has not been loaded yet for context" something.
Is there anybody coming the same issue previously? thanks advance!

GetExportedValues<MyType> returns nothing, I can see the parts

I have a strange MEF problem, I tested this in a test project and it all seems to work pretty well but for some reason not working in the real project
This is the exporting code
public void RegisterComponents()
{
_registrationBuilder = new RegistrationBuilder();
_registrationBuilder
.ForTypesDerivedFrom(typeof(MyType))
.SetCreationPolicy(CreationPolicy.NonShared)
.Export();
var catalog = new AggregateCatalog();
catalog.Catalogs.Add(new AssemblyCatalog(typeof(MyType).Assembly, _registrationBuilder));
var directoryCatalog = new DirectoryCatalog(PathToMyTypeDerived, _registrationBuilder);
catalog.Catalogs.Add(directoryCatalog);
_compositionContainer = new CompositionContainer(catalog);
_compositionContainer.ComposeParts();
var exports = _compositionContainer.GetExportedValues<MyType>();
Console.WriteLine("{0} exports in AppDomain {1}", exports.Count(), AppDomain.CurrentDomain.FriendlyName);
}
exports count is 0 :( Any ideas why?
IN the log file I have many of this
System.ComponentModel.Composition Information: 6 : The ComposablePartDefinition 'SomeOthertype' was ignored because it contains no exports.
Though I would think this is ok because I wasn' interested in exporting 'someOtherType'
UPDATE: I found this link but after debuging over it I am not wiser but maybe I m not following up properly.
Thanks for any pointers
Cheers
I just had the same problem and this article helped me a lot.
It describes different reasons why a resolve can fail. One of the more important ones is that the dependency of a dependency of the type you want to resolve is not registered.
What helped me a lot was the the trace output that gets written to the Output window when you debug your application. It describes exactly the reasons why a type couldn't be resolved.
Even with this output. you might need to dig a little bit, because I only got one level deep.
Example:
I wanted to resolve type A and I got a message like this:
System.ComponentModel.Composition Warning: 1 : The ComposablePartDefinition 'Namespace.A' has been rejected. The composition remains unchanged. The changes were rejected because of the following error(s): The composition produced multiple composition errors, with 1 root causes. The root causes are provided below. Review the CompositionException.Errors property for more detailed information.
1) No exports were found that match the constraint:
ContractName Namespace.IB
RequiredTypeIdentity Namespace.IB
Resulting in: Cannot set import 'Namespace.A..ctor (Parameter="b", ContractName="namespace.IB")' on part 'Namespace A'.
Element: Namespace.A..ctor (Parameter="b", ContractName="Namespace.IB") --> Namespace.A --> AssemblyCatalog (Assembly="assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=...")
But I clearly saw a part for Namespace.IB. So, in the debugger, I tried to resolve that one. And I got another trace output. This time it told me that my implementation of Namespace.IB couldn't be resolved because for one of its imports there was a missing export, so basically the same message as above, just with different types. And this time, I didn't find a part for that missing import. Now I knew, which type was the real problem and figure out, why no registration happened for it.

dojo problems with creating new dom nodes

I am trying to create a new node that is a child of an existing ul node I have in the document, but no matter how I proceed I seem to get an error. The following two ways are the ways I have tried:
var ul = dojo.query('#highlights ul').0;
dojo.place("<li></li>", ul);
and I get a message:
TypeError: refNode.appendChild is not
a function
This message didn't make sense to me because on checking the value of ul I find that it is an element and it has two children already...I went on to try the more programmatic build allowed by dojo.create(); via the following lines:
var ul = dojo.query('#highlights ul').0;
dojo.create("li", null, ul);
and this produced an error:
TypeError: doc is undefined
which is really baffling me since the ul element is defined...I decided that I should just try adding the same li element to the doc body, so I went and tried:
dojo.create("li", null, dojo.body());
which returned without error, but on checking the document source nothing changed....So is there something I am missing? I assume that I don't need to require any files to use these, is that an incorrect assumption? the load function that contains this code is in an external file to help me organize my code, could this be causing the problem?
this function is called in the dojo.addOnLoad block to prevent problems when called async, could this be part of the problem?
Your problem is that you're not getting the node from your query.
It should be:
var ul = dojo.query('#highlights ul')[0];
not
var ul = dojo.query('#highlights ul').0;
I'm surprised your browser didn't error on the dojo.query line.
Probably xenador forgot to enclose dom manipulations in dojo.ready. doc is underfined == Document wasn't ready.