Karma-Jasmine: Error During Loading - unit-testing

I just got done setting up karma-jasmine in my solution. On the initial test run, I get an error:
Error during loading: Uncaught TypeError: $(...).tooltip is not a
function in src.js
tooltip being a function from bootstrap.js. This library is being pulled into my .asp file along with my src.js file being tested. Is there a way to let karma-jasmine know that this function does indeed exist?

Related

Sortablejs - sortablejs_1.MultiDrag is not a constructor in unit tests

I am using ngx-sortable library and it's my first contact with it. According to documentation I've included the line below to have MultiDrag.
Sortable.mount(new MultiDrag(), new Swap());
Component works fine.
But when I try to run my unit tests it fails with an error:
TypeError: sortablejs_1.MultiDrag is not a constructor
SortablejsModule was imported in the spec file. I spent some time on searching the internet but I couldn't find the solution. Do you know what is the reason of that error?
Thank you in advance

Plugin makes options dropdown not working in opencart product

I have a problem with Option tab on Add/Edit product. The problem is that when I installed the extension Autocomplete No More and when I choose Option it throws this error
Fatal error: Uncaught Error: Call to a member function getOptionData() on null in /../ocartdata/storage/modification/admin/controller/catalog/option.php:437
in option.php line 437 is
$option_data = $this->model_extension_catalog_autocomplete_no_more->getOptionData($this->request->post['option_id']);
And full function is this one
public function getOptionData() {
if (isset($this->request->post['option_id'])) {
$this->load->language('catalog/option');
$this->load->model('catalog/autocomplete_no_more');
$this->load->model('tool/image');
$option_data = $this->model_extension_catalog_autocomplete_no_more->getOptionData($this->request->post['option_id']);
$this->response->setOutput(json_encode($option_data));
}
}
Is anyone has an idea why this throws null?
Issue:
You are trying to call a method of an Object
$this->model_extension_catalog_autocomplete_no_more
with the extension in the object name.
but then you are loading the model without the extension in the path:
$this->load->model('catalog/autocomplete_no_more')
So obviously the Error signals that you have not yet defined this object
Call to a member function getOptionData() on null
Solution:
Fix it by adding extension to the path:
$this->load->model('extension/catalog/autocomplete_no_more')
or remove if from the object name:
$this->model_catalog_autocomplete_no_more

Better errors with Ember

Is there a way to have clearer error messages when something is wrong with ember?
For exemple, I have this error 05:10:32,332 Error: Assertion Failed: A helper named 'eq' could not be found1 vendor.self-4fd4ab06f1f66c1cec72e1ec3a2c99328df792e46fb1fdcd0258c341b30a7c3b.js:24472:0
. This error is not the subject of the question, this is just an example.
I have no idea where is eq. The console indicated this function :
function EmberError() {
var tmp = Error.apply(this, arguments);
// Adds a `stack` property to the given error object that will yield the
// stack trace at the time captureStackTrace was called.
// When collecting the stack trace all frames above the topmost call
// to this function, including that call, will be left out of the
// stack trace.
// This is useful because we can hide Ember implementation details
// that are not very helpful for the user.
if (Error.captureStackTrace) {
Error.captureStackTrace(this, _emberMetalCore.default.Error);
}
// Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.
for (var idx = 0; idx < errorProps.length; idx++) {
this[errorProps[idx]] = tmp[errorProps[idx]];
}
}
This is not related to my problem.
Obviouly, I searched eq in my code and I have no results. I suppose this is in a module but using grep is very ineffective.
Sometimes there is a stacktrace but its not very efficient too. To find an addon or the source in my code in a big vendor.js or myapp.js is not ideal.
Is there a better solution?
I think something in one of your addons or other third party code is using the ember-truth-helpers addon.
vendor.js typically contains third party code you've imported, not code that you've wrote.
As to the basic issue, it is really up to the maker of the third party code you've imported to document its dependencies and to ensure they are installed when you install that dependency. This really is not a failing of Ember itself, it has told you that there is no helper named eq and has given you the line number in the precompiled template where the eq was used. You can use the sources tab in Chrome to scroll to line 24472 in vendor.self-4fd4ab06f1f66c1cec72e1ec3a2c99328df792e46fb1fdcd0258c341b30a7c3b.js

opencv\modules\core\src\persistence.cpp:2697: error: (-27) NULL or empty buffer in function cvOpenFileStorage

I am trying to run a facedetection application and I get the following error:
Unexpected Standard exception from MEX file.
What() is:..\..\..\..\opencv\modules\core\src\persistence.cpp:2697: error: (-27)
NULL or empty buffer in function cvOpenFileStorage
If you're using haarcascade_frontalface_default.xml, check the xml file content.
The first 3 lines should be:
<?xml version="1.0"?>
<!--
Stump-based 24x24 discrete(?) adaboost frontal face detector.
I inadvertently downloaded the html that linked to the haarcascade_frontalface_default.xml file instead of the xml itself and got the same error you did.
You should provide some code and information.Nevertheless the error indicates that it can not access the haarcascade file. I suggest you make sure you have the "xml" in the same folder as your code (e.g. "ViewController.mm") and check permissions. additionally Assuming you are using Objective-c or swift:
1-check the file is in your Xcode project; and, if it is,
2-check it's included in the 'Copy Bundle Resources' phase underneath your selected Target (in the project tree view on the left in the normal Xcode window layout) and, if it is,
3-look inside the generated application bundle (find your product, right click, select 'Reveal in Finder', from Finder right click on the app and select 'Show Package Contents', then look for your file in there) to make sure that it's there.
I've got the same problem, and then I figure out what's the problem
First
Add file haarcascade_frontalface_default.xml to xcode project
make sure when you add the xml file with option below:
Destination: Copy items if need [check]
Added Folder: Create Folder References [check]
Add to targets: Your Project target [check]
Second
in you Wrapper.mm file add this code to your obj-c function:
const NSString* cascadePath = [[NSBundle mainBundle]pathForResource:#"haarcascade_frontalface_default" ofType:#"xml"];
or in case you wanna load the xml file, use this code:
cv::CascadeClassifier classifier;
const NSString* cascadePath = [[NSBundle mainBundle]pathForResource:#"haarcascade_frontalface_default" ofType:#"xml"];
classifier.load([cascadePath UTF8String]);
this actually fixes my problem, anywaythis question has been questioned for a long time but I hope someone face this problem can come to this answer and help them solve their problem like mine, cheer.

"Unexpected line" exception when using component load rules for RTC Jazz build engine

I have a component named MyComponent with the following folder structure in RTC:
/MyProject
/MyProject/TestFile.txt
/MyProject/Folder1
/MyProject/Folder1/loadrules.txt
/MyProject/Folder1/TestFile2.txt
And this is what I have in my loadrules.txt file::
versionableName=/MyProject/TestFile.txt
I've specified the loadrules.txt file in my build definition for this component as the component load rule, but when the build runs, I'm getting the following exception when it tries to fetch the files:
com.ibm.team.repository.common.TeamRepositoryException: Unexpected line "versionableName=/MyProject/TestFile.txt" encountered in build load rules for component "MyComponent"
at com.ibm.team.filesystem.client.internal.load.LoadRule.getRules(LoadRule.java:176)
at com.ibm.team.filesystem.client.internal.load.LoadRule.addLoadRules(LoadRule.java:101)
at com.ibm.team.build.internal.scm.ComponentLoadRules.getLoadRules(ComponentLoadRules.java:134)
at com.ibm.team.build.internal.engine.JazzScmPreBuildParticipant.preBuild(JazzScmPreBuildParticipant.java:235)
at com.ibm.team.build.internal.engine.BuildLoop.invokePreBuildParticipants(BuildLoop.java:844)
at com.ibm.team.build.internal.engine.BuildLoop$2.run(BuildLoop.java:650)
at java.lang.Thread.run(Thread.java:662)
Any idea what I'm doing wrong? I've tried following the example here but I can't figure why it's not working for me. Regardless of what I put in the loadrules.txt file (nothing/empty string, random garbage text, etc.), I still get this exception for the first line of the file.
This is in RTC 3.0
This kind of error is likely to be an encoding issue.
One way to test that is to create the loadrules.txt through the scm command-line interface, as detailed in "Reference > Source control command line reference > scm > create"
scm create loadrules [options]
The OP holic87 confirms:
I just used Notepad++ to recreate the text file and it's working as expected now.