0
votes

I am facing a strange issue while running my jasmine tests in bamboo build. Tests fail randomly with the following error:

Failed: can't convert undefined to object build   18-Nov-2019
03:08:56      ./node_modules/@angular/core/fesm5/core.js/</ReflectionCapabilities.prototype._ownPropMetadata@http://localhost:9876/_karma_webpack_/vendor.js:56242:13
build 18-Nov-2019
03:08:56      ./node_modules/@angular/core/fesm5/core.js/</ReflectionCapabilities.prototype.propMetadata@http://localhost:9876/_karma_webpack_/vendor.js:56265:31
build 18-Nov-2019
03:08:56      ./node_modules/@angular/core/fesm5/core.js/</ReflectionCapabilities.prototype.propMetadata@http://localhost:9876/_karma_webpack_/vendor.js:56260:40
build 18-Nov-2019
03:08:56      ./node_modules/@angular/platform-browser-dynamic/fesm5/platform-browser-dynamic.js/JitReflector.prototype.propMetadata@http://localhost:9876/_karma_webpack_/vendor.js:117510:16
build 18-Nov-2019
03:08:56      ./node_modules/@angular/compiler/fesm5/compiler.js/DirectiveResolver.prototype.resolve@http://localhost:9876/_karma_webpack_/vendor.js:32740:40
build 18-Nov-2019
03:08:56      ./node_modules/@angular/compiler/fesm5/testing.js/MockDirectiveResolver.prototype.resolve@http://localhost:9876/_karma_webpack_/vendor.js:54975:46
build 18-Nov-2019
03:08:56      ./node_modules/@angular/compiler/fesm5/compiler.js/CompileMetadataResolver.prototype.getNonNormalizedDirectiveMetadata@http://localhost:9876/_karma_webpack_/vendor.js:40491:23
build 18-Nov-2019
03:08:56      ./node_modules/@angular/compiler/fesm5/compiler.js/CompileMetadataResolver.prototype.loadDirectiveMetadata@http://localhost:9876/_karma_webpack_/vendor.js:40422:18
build 18-Nov-2019
03:08:56      ./node_modules/@angular/compiler/fesm5/compiler.js/JitCompiler.prototype._loadModules/</<@http://localhost:9876/_karma_webpack_/vendor.js:53988:31
build 18-Nov-2019
03:08:56      ./node_modules/@angular/compiler/fesm5/compiler.js/JitCompiler.prototype._loadModules/<@http://localhost:9876/_karma_webpack_/vendor.js:53987:13
build 18-Nov-2019
03:08:56      ./node_modules/@angular/compiler/fesm5/compiler.js/JitCompiler.prototype._loadModules@http://localhost:9876/_karma_webpack_/vendor.js:53984:9
build 18-Nov-2019
03:08:56      ./node_modules/@angular/compiler/fesm5/compiler.js/JitCompiler.prototype._compileModuleAndAllComponents@http://localhost:9876/_karma_webpack_/vendor.js:53969:31
build 18-Nov-2019
03:08:56      ./node_modules/@angular/compiler/fesm5/compiler.js/JitCompiler.prototype.compileModuleAndAllComponentsAsync@http://localhost:9876/_karma_webpack_/vendor.js:53928:32
build 18-Nov-2019
03:08:56      ./node_modules/@angular/platform-browser-dynamic/fesm5/platform-browser-dynamic.js/CompilerImpl.prototype.compileModuleAndAllComponentsAsync@http://localhost:9876/_karma_webpack_

After couple of re runs test start passing. I am unable to indenitify the root cause. Evey run fails a different test.

1

1 Answers

1
votes

It seems that there are dependencies between your Jasmine tests.

I recommend to use "focused it" to go through your test cases and find those who fail when the other tests did not run before him. Particularly this means that you iterate through your test cases, you change an "it" to "fit" and you check if it passes if only that one test runs. If it passes you change back the "fit" to "it" and you go further to the next one. If you find a failing one, you can figure out, what is its dependency and fix it.

There is an alternative for "describe" as well written as "fdescribe". With "fdescribe" only the tests in that describe run. This way you are able to find the dependencies between "describe"-s.

More about "fit" and "fdescribe" here: https://jasmine.github.io/api/3.0/global