Require not defined error: Karma and Jasmine - angularjs

I am testing nodejs API and I included file in karma.config.js
I got the following error: Require not defined.
Then as per the suggestions given in other posts I added browserify to that file, but now I am getting different error.
` files: [
'poc/app/api.js', // file where there is require statements
'tests/sample.test.js' // my test file
],
preprocessors: {
'poc/app/api.js':['browserify']
},`
Uncaught TypeError: Cannot read property 'prototype' of undefined
Please let me know how to resolve this.

Uncaught TypeError: Cannot read property 'prototype' of undefined
This error should also include a file name and line number. Since you didn't include that information or the source code, the only advice that can be given here is to check that line of that file, see what can be undefined, track how it got there, where it should be defined but is not and fix the problems that responsible for that.

Related

TypeError: Cannot read property 'twoArgumentPooler' of undefined

Recently we have upgraded the react-native-web package to latest version 0.17.0 From that time we are getting the issue TypeError: Cannot read property 'twoArgumentPooler' of undefined while running yarn test
To analyse this issue, gone through the code which is implemented by our developers but we didn't have anything like twoArgumentPooler but it's available in react-native-web package in the path
at Object.<anonymous> (node_modules/react-native-web/dist/cjs/exports/Touchable/BoundingDimensions.js:19:46)
How to resolve this issue
Can you show your jest config file? I had a similar issue and it turned out that I was (manually) setting up the moduleNameMapper incorrectly. I had the following:
moduleNameMapper: {
'react-native': 'react-native-web',
},
which, upon running the tests, effectively invalidated an import on line 10 inside react-native-web/dist/exports/Touchable/BoundingDimensions.js (the file mentioned in your stacktrace) and surely a lot of other imports.
This
import PooledClass from '../../vendor/react-native/PooledClass';
var twoArgumentPooler = PooledClass.twoArgumentPooler;
turned into this (notice the changed and incorrect path)
import PooledClass from '../../vendor/react-native-web/PooledClass';
var twoArgumentPooler = PooledClass.twoArgumentPooler;
This ultimately resulted in the exact same error as you got, and was resolved by correctly defining the remapper entry like this:
moduleNameMapper: {
'^react-native$': 'react-native-web',
},
Hope it helps! If nothing else, perhaps this will help someone in the future!

error ReferenceError: System is not defined file:///E:/PetsDemoAj/index.html Line 17

I am new in angular JS2 and tried this sample project provided in the given link http://embed.plnkr.co/eBv3hZZSk9Tx3joykvSQ/ I have tried this example , and getting error ReferenceError: System is not defined file:///E:/PetsDemoAj/index.html Line 17,in console; PetsDemoAj is my project name. Thanks in adavance
Its about your systemjs.config.js file, you need to declare 'System', because compilator doesnt recognize this, add this line upon line where System is called:
declare var System: any;
this should fix the problem

clean-css TypeError cannot read property '0' of null

I am trying to minify my code and i always get this error when it runs clean-css.
/home/k1ngsley/Projects/mobile_rea/partners-mobile-app/node_modules/clean-css/lib/selectors/extractor.js:66
return name.replace(/^\-\w+\-/, '').match(/([a-zA-Z]+)/)[0].toLowerCase();
^
TypeError: Cannot read property '0' of null
at findNameRoot (/home/k1ngsley/Projects/mobile_rea/partners-mobile-app/node_modules/clean-css/lib/selectors/extractor.js:66:59)
at extract (/home/k1ngsley/Projects/mobile_rea/partners-mobile-app/node_modules/clean-css/lib/selectors/extractor.js:36:9)
at restructure (/home/k1ngsley/Projects/mobile_rea/partners-mobile-app/node_modules/clean-css/lib/selectors/restructure.js:297:22)
at optimize (/home/k1ngsley/Projects/mobile_rea/partners-mobile-app/node_modules/clean-css/lib/selectors/advanced.js:71:5)
at minify (/home/k1ngsley/Projects/mobile_rea/partners-mobile-app/node_modules/clean-css/lib/clean.js:228:5)
at whenSourceMapReady (/home/k1ngsley/Projects/mobile_rea/partners-mobile-app/node_modules/clean-css/lib/clean.js:135:7)
at Object.whenDone (/home/k1ngsley/Projects/mobile_rea/partners-mobile-app/node_modules/clean-css/lib/clean.js:155:14)
at processNext (/home/k1ngsley/Projects/mobile_rea/partners-mobile-app/node_modules/clean-css/lib/imports/inliner.js:105:13)
at importFrom (/home/k1ngsley/Projects/mobile_rea/partners-mobile-app/node_modules/clean-css/lib/imports/inliner.js:79:10)
at ImportInliner.process (/home/k1ngsley/Projects/mobile_rea/partners-mobile-app/node_modules/clean-css/lib/imports/inliner.js:38:10)
Error: Hook failed with error code 8: /home/k1ngsley/Projects/mobile_rea/partners-mobile-app/hooks/after_prepare/070_uglify.js
at /home/k1ngsley/npm/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:195:23
at _rejected (/home/k1ngsley/npm/lib/node_modules/cordova/node_modules/q/q.js:797:24)
at /home/k1ngsley/npm/lib/node_modules/cordova/node_modules/q/q.js:823:30
at Promise.when (/home/k1ngsley/npm/lib/node_modules/cordova/node_modules/q/q.js:1035:31)
at Promise.promise.promiseDispatch (/home/k1ngsley/npm/lib/node_modules/cordova/node_modules/q/q.js:741:41)
at /home/k1ngsley/npm/lib/node_modules/cordova/node_modules/q/q.js:557:44
at flush (/home/k1ngsley/npm/lib/node_modules/cordova/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:448:13)
I have read different posts that says remove commented lines etc but all hasnt worked out for me.
Any one has any other ideas or ways to solve this issue
Take a look at min.css utility that is more fastest and fault-tolerance.

Parsley js remote config. Error browser dev console

I followed the Custom remote validators documentation
I have <script href="parsley.remote.js"></script> before <script href="parsley.js"></script> just before the end of html body and I'm seeing the following message on the console of Chrome Developer Tools:
Uncaught TypeError: Cannot read property 'on' of undefined(anonymous function) # parsley.remote.js:267(anonymous function) # parsley.remote.js:271
Part of paryley.remote.js code :
window.Parsley.on('form:submit', function () {
this._remoteCache = {};
});
On Firebug the error console message is
TypeError: window.Parsley is undefined
window.Parsley.on('form:submit', function () {
A small lab just a test html page with source dist js parsley
If I invert file reference parsley.remote.js and parsley.js, the error disappears, but according to the documentation, it's not the right way.
It's was bug, fixed in 2.1.3+.
Only include the remote version (assuming you need it).

mpdf no output and php errors in mpdf.php

I'm trying to generate a pdp file in a cakephp application. Therefore, I use the mpdf library as a vendor. But when I try to make a even very simple output it doesn't work. Then when I use the debug property, it shows php errors in the mpdf.php file.
Here is my source code:
<?php
$mpdf=new mPDF();
$mpdf->WriteHTML('hello');
$mpdf->debug = true;
$mpdf->Output();
exit;
?>
And these are the errors shown in the browser:
Notice (8): Undefined index: BODY [APP\vendors\MPDF54\mpdf.php, line 14242]
Notice (8): Undefined index: BODY>>ID>> [APP\vendors\MPDF54\mpdf.php, line 14288]
Notice (8): Undefined offset: -1 [APP\vendors\MPDF54\mpdf.php, line 14421]
Thank you for your help!
This is not a CakePHP problem but related to the library you're using.
Read about how to use the WriteHTML() method.
http://mpdf1.com/manual/index.php?tid=121
And try passing 2 as the 2nd argument.
$mpdf->WriteHTML('hello', 2);
If this still does not work read the documentation, check the examples there.
This is caused by buggy mpdf code. It depends on error (level "notice") reporting to be switched off (it switches it off itself). But if you handle errors some nonstandard way, it is problem..
I solved it by ignoring errors from mpdf.php file in my custom error handler.
I was using my custom error reporting via set_error_handler();

Resources