I get an error message -"ReferenceError: module is not defined" when trying to test angular js code.
test script [testSpec.js]
describe('Project controllers', function() {
beforeEach(module('project'));
describe('ListCtrl', function() {
expect(1).toBe(1);
});
});
I have the following entries in my html file
<script src="angular.min.js"></script>
<script src="angular-resource.min.js"></script>
<script src="angular-mocks.js"></script>
followed by my test script - testSpec.js
I specifically included angular.js and angular-mocks.js again. I get to see the following error message
Chrome 31.0.1650 (Windows 7) Project controllers ListCtrl should create 11 records FAILED
TypeError: Object #<Object> has no method 'apply'
Error: Unknown provider: ProjectsProvider <- Projects
at Error (<anonymous>)
at c:/Angular/angular-phonecat/app/angular.min.js:30:24
at Object.c [as get] (c:/Angular/angular-phonecat/app/angular.min.js:27:310)
at c:/Angular/angular-phonecat/app/angular.min.js:30:109
at c (c:/Angular/angular-phonecat/app/angular.min.js:27:310)
at d (c:/Angular/angular-phonecat/app/angular.min.js:27:444)
at Object.instantiate (c:/Angular/angular-phonecat/app/angular.min.js:29:80)
at c:/Angular/angular-phonecat/app/angular.min.js:53:80
at null.<anonymous> (c:/Angular/angular-phonecat/app/testSpec.js:10:12)
at Object.d [as invoke] (c:/Angular/angular-phonecat/app/angular.min.js:28:464)
Error: Declaration Location
at window.jasmine.window.inject.angular.mock.inject (c:/Angular/angular-phonecat/app/angular-mocks.js:1781:2
Here is the complete error
5) at null.<anonymous> (c:/Angular/angular-phonecat/app/testSpec.js:8:34)\n
at null.<anonymous> (c:/Angular/angular-phonecat/app/testSpec.js:6:2)\n
at c:/Angular/angular-phonecat/app/testSpec.js:2:1
Chrome 31.0.1650 (Windows 7) Project controllers ListCtrl should contain new fields FAILED
TypeError: Object #<Object> has no method 'apply'
Error: Unknown provider: ProjectsProvider <- Projects
I'm suspecting that you're missing some include files in you karma config file. Specifically, make sure you load angular.js.
Did you include angular-mocks.js ?
That should solve your problem.
You need that for it to work.
Related
I've followed the instructions at GitHub, but the example doesn't work.
The app shows "Starting database".
At the browser console there is this error:
Uncaught (in promise) TypeError: storage is undefined
_callee6$ http://127.0.0.1:20202/dist/rxdb.browserify.js:11032
tryCatch http://127.0.0.1:20202/dist/rxdb.browserify.js:70936
invoke http://127.0.0.1:20202/dist/rxdb.browserify.js:71167
defineIteratorMethods http://127.0.0.1:20202/dist/rxdb.browserify.js:70992
asyncGeneratorStep http://127.0.0.1:20202/dist/rxdb.browserify.js:14068
_next http://127.0.0.1:20202/dist/rxdb.browserify.js:14090
_asyncToGenerator http://127.0.0.1:20202/dist/rxdb.browserify.js:14097
_asyncToGenerator http://127.0.0.1:20202/dist/rxdb.browserify.js:14086
_createRxDatabaseStorageInstances http://127.0.0.1:20202/dist/rxdb.browserify.js:11060
createRxDatabaseStorageInstances http://127.0.0.1:20202/dist/rxdb.browserify.js:11017
_callee7$ http://127.0.0.1:20202/dist/rxdb.browserify.js:11075
tryCatch http://127.0.0.1:20202/dist/rxdb.browserify.js:70936
invoke http://127.0.0.1:20202/dist/rxdb.browserify.js:71167
defineIteratorMethods http://127.0.0.1:20202/dist/rxdb.browserify.js:70992
asyncGeneratorStep http://127.0.0.1:20202/dist/rxdb.browserify.js:14068
_next http://127.0.0.1:20202/dist/rxdb.browserify.js:14090
_asyncToGenerator http://127.0.0.1:20202/dist/rxdb.browserify.js:14097
_asyncToGenerator http://127.0.0.1:20202/dist/rxdb.browserify.js:14086
_prepare http://127.0.0.1:20202/dist/rxdb.browserify.js:11104
prepare http://127.0.0.1:20202/dist/rxdb.browserify.js:11064
createRxDatabase http://127.0.0.1:20202/dist/rxdb.browserify.js:11142
<anonymous> http://127.0.0.1:20202/main.js:33
When I try to add a hero and click the "Insert" button this error appears at the console:
Uncaught ReferenceError: col is not defined
addHero http://127.0.0.1:20202/main.js:97
onclick http://127.0.0.1:20202/:1
Ist this a bug or am I missing something?
According to the rxdb v10 release notes:
"...many (example projects) are outdated and need updates."
I was as well not able to get it working.
New to TestCafe .. just copied the code from their site and executed it.
import { Selector } from 'testcafe';
fixture `Getting Started`
.page `http://devexpress.github.io/testcafe/example`;
test('My first test', async t => {
await t
.typeText('#developer-name', 'John Smith')
.click('#submit-button');
});
The browsers are connected successfully but script is not executed and got error after some time
Nimits-MacBook-Pro:TestCafe nimit$ testcafe chrome demo.js
ERROR Was unable to open the browser "chrome:" due to error.
TypeError: Cannot read property 'split' of undefined
at Object.callee$0$0$ (/usr/local/lib/node_modules/testcafe/node_modules/testcafe-browser-tools/lib/api/find-window.js:111:36)
at tryCatch (/usr/local/lib/node_modules/testcafe/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:72:40)
at Generator.invoke [as _invoke] (/usr/local/lib/node_modules/testcafe/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:334:22)
at Generator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/testcafe/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:105:21)
at tryCatch (/usr/local/lib/node_modules/testcafe/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:72:40)
at invoke (/usr/local/lib/node_modules/testcafe/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:146:20)
at /usr/local/lib/node_modules/testcafe/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:154:13
Environment
nodejs version - 10.16.0
npm - 6.9.0
OS - MACOS catalina
TestCafe - 1.6.0
Suddenly im getting error when i start ionic project
TypeError: Cannot read property 'substr' of undefined
at Function.<anonymous> (D:\Work\Prince\TakeToTake\node_modules\source-map\lib\source-node.js:115:26)
at Array.forEach (native)
at BasicSourceMapConsumer.SourceMapConsumer_eachMapping [as eachMapping] (D:\Work\Prince\TakeToTake\node_modules\source-map\lib\sour
at Function.SourceNode_fromStringWithSourceMap [as fromStringWithSourceMap] (D:\Work\Prince\TakeToTake\node_modules\source-map\lib
at SourceMapSource.node (D:\Work\Prince\TakeToTake\node_modules\webpack-sources\lib\SourceMapSource.js:39:21)
at ReplaceSource.node (D:\Work\Prince\TakeToTake\node_modules\webpack-sources\lib\ReplaceSource.js:70:30)
at CachedSource.node (D:\Work\Prince\TakeToTake\node_modules\webpack-sources\lib\CachedSource.js:18:24)
at D:\Work\Prince\TakeToTake\node_modules\webpack-sources\lib\ConcatSource.js:37:50
at Array.map (native)
at ConcatSource.node (D:\Work\Prince\TakeToTake\node_modules\webpack-sources\lib\ConcatSource.js:36:63)
Please Help
Found the error
i was implement two Component inside one TS file that's why the nodeJS confuse to run which component
now i created another ts file to implement the component
thanks for the comments
I'm having some difficulty with gulp-angular-templatecache. I have a gulpfile with a task:
gulp.task('templates', function() {
return gulp.src(paths.angularTemplates)
.pipe(templateCache())
/*.pipe(gulp.dest('javascript/angular'))*/;
});
I'm not sure why but the following error is thrown when piping to gulp-angular-templatecache and throws:
stream.js:74
throw er; // Unhandled stream error in pipe.
^
TypeError: Cannot read property 'toString' of null
at templateCacheFile (/home/vagrant/app/node_modules/gulp-angular-templatecache/index.js:89:40)
at wrappedMapper (/home/vagrant/app/node_modules/gulp-angular-templatecache/node_modules/event-stream/node_modules/map-stream/index.js:84:19)
at Stream.stream.write (/home/vagrant/app/node_modules/gulp-angular-templatecache/node_modules/event-stream/node_modules/map-stream/index.js:96:21)
at Stream.method [as write] (/home/vagrant/app/node_modules/gulp-angular-templatecache/node_modules/event-stream/node_modules/duplexer/index.js:47:39)
at write (/home/vagrant/app/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:623:24)
at flow (/home/vagrant/app/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:632:7)
at DestroyableTransform.pipeOnReadable (/home/vagrant/app/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:664:5)
at emitNone (events.js:67:13)
at DestroyableTransform.emit (events.js:166:7)
at emitReadable_ (/home/vagrant/app/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:448:10)
I'm not sure what problem this error is related to. Any help would be greatly appreciated.
Many thanks.
there was a newer gulp-angular-templatecache version which broke the it. Ended up specifying a specific version in the gulpfile
In my project this was caused by a folder name with a dot inside.
So, I had a folder called folder_name.html and had to rename it to folder_name.
(Using gulp-angular-templatecache version 1.9.1)
I recently tried Humanizer.Js. I added a nuget reference of the same from here, and added it in my page as <script src="~/Scripts/humanizer/humanizer.js"></script>.
However in my page load I am getting an error:
"Uncaught TypeError: Cannot read property 'prototype' of undefined" at humanizer.js:409. The stack trace looks like below:
Uncaught TypeError: Cannot read property 'prototype' of undefined
__extends # humanizer.js:409
(anonymous function) # humanizer.js:416
Humanizer.Configuration.Humanizer.Configuration # humanizer.js:422
Humanizer # humanizer.js:424
(anonymous function) # humanizer.js:426
I have also created a plunk here to replicate the error. Also note that .humanize() also doesn't work.
Any suggestions?
I just released version 1.5 on NuGet, should fix your error