Open aubrey-fowler opened 4 years ago
Im also interested in a solution for this ! :)
Thank you for the repo @aubrey-fowler - we'll take a look!
I found @gsavchenko 's blog (https://quabr.com/57186925/how-to-implement-unit-tests-in-nativescript-using-testbed-and-jasmine) maybe he can help us out about this problem here?
At least @gsavchenko set it up for nativescript & angular so he has maybe deep insights? :)
@saschaarthur maybe I'll start a blog soon! but you linked a web scrapper that took my StackOverflow question. You will not be able to use css selectors and I believe that my current repo was working (although it maybe outdated now).
Let me know if you have any further questions as this has been marked as resolved by me.
Thanks @gsavchenko.
sadly i didnt found any example in your repo about a service provider, also sadly as you said its very outdated and doesnt match the "shared code project" style nowadays .
If im blind let me know
Then my hope goes in @NathanWalker
@saschaarthur yeah no problem I am also curious, you are not missing anything. If I can spend some time looking at it I might but I'm sure @NathanWalker may know more as well.
Thanks so far!
Anyways to be clear: Im facing a reflection issue with his repository.
As far as i get it: The Test-Framework doesnt know how to bootstrap the nativescript/angular application. Because of the private Service in the constructor.
The error message he mentions (no reachable hosts) above is something else i guess?
He also put an example how to "manually" generate the needed Service (this tests are well passing), but the Dependency Injection should be somehow possible with the Test-Framework itself i would say?
This here is what happens when i include the test (https://github.com/aubrey-fowler/NativeScriptUnitTests/blob/master/src/tests/items.component.ts#L10) (by removing the xdescribe), into the tests.
The Stack then fails to do the depenency Injection:
error properties: Object({ originalStack: 'Error: Can't resolve all parameters for ApplicationModule: (?).
at ZoneAwareError (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:85903:33)
at syntaxError (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:9475:17)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getDependenciesMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28631:35)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getTypeMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28523:26)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28391:24)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/com ...
Error: Can't resolve all parameters for ApplicationModule: (?).
at ZoneAwareError (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:85903:33)
at syntaxError (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:9475:17)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getDependenciesMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28631:35)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getTypeMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28523:26)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28391:24)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleSummary (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28201:35)
at file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28288:55
at <Jasmine>
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28266:49)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleSummary (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28201:35)
at file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28288:55
at <Jasmine>
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28266:49)
at JitCompiler.push.../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._loadModules (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:34433:51)
at JitCompiler.push.../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndAllComponents (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:34421:36)
error properties: Object({ originalStack: 'Error: Can't resolve all parameters for ApplicationModule: (?).
at ZoneAwareError (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:85903:33)
at syntaxError (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:9475:17)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getDependenciesMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28631:35)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getTypeMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28523:26)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28391:24)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/com ...
Error: Can't resolve all parameters for ApplicationModule: (?).
at ZoneAwareError (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:85903:33)
at syntaxError (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:9475:17)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getDependenciesMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28631:35)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getTypeMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28523:26)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28391:24)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleSummary (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28201:35)
at file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28288:55
at <Jasmine>
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28266:49)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleSummary (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28201:35)
at file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28288:55
at <Jasmine>
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28266:49)
at JitCompiler.push.../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._loadModules (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:34433:51)
at JitCompiler.push.../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndAllComponents (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:34421:36)
For sure i was asking google for some hours already...
Spend again some time on it and im not able to get it running with dependency injection/reflection..
Any updates / something i can support with here?
@NathanWalker any updates on this?
@saschaarthur thanks for the ping - been working on Angular 10 support to bring everything up to date - we were originally planning on rewriting the entire Angular integration from scratch with clean slate but given Angular 10 announcement last week we'll be planning to do that for Angular 11. If there are any delays on Angular 10 in next day I'm going to circle back here.
This error though Can't resolve all parameters for ApplicationModule: (?)
is a common error when the --env.aot
flag is missing. You are using that flag on your command for sure?
@NathanWalker doesnt work either:
tns test android --env.aot
Searching for devices...
File change detected. Starting incremental webpack compilation...
(node:6352) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
i 「wdm」: wait until bundle finished: noop
i 「wdm」: wait until bundle finished: noop
i 「wdm」: wait until bundle finished: noop
i 「wdm」: wait until bundle finished: noop
File change detected. Starting incremental webpack compilation...
Webpack compilation complete. Watching for file changes.
Webpack compilation complete. Watching for file changes.
i 「wdm」: Hash: a7620b6683bda0561d99
Version: webpack 4.27.1
Time: 14088ms
Built at: 2020-09-16 12:03:44 PM
Asset Size Chunks Chunk Names
runtime.js 5.95 KiB runtime [emitted] runtime
src\tests\example.bundle.js 366 bytes src\tests\example [emitted] src\tests\example
src\tests\item.service.bundle.js 3.5 KiB src\tests\item.service [emitted] src\tests\item.service
src\tests\items.component.bundle.js 7.95 KiB src\tests\items.component [emitted] src\tests\items.component
src\tests\setup.bundle.js 1.91 KiB src\tests\setup [emitted] src\tests\setup
vendor.bundle.js 6.64 MiB vendor [emitted] vendor
Entrypoint src\tests\item.service = runtime.js vendor.bundle.js src\tests\item.service.bundle.js
Entrypoint src\tests\example = runtime.js src\tests\example.bundle.js
Entrypoint src\tests\items.component = runtime.js vendor.bundle.js src\tests\items.component.bundle.js
Entrypoint src\tests\setup = runtime.js vendor.bundle.js src\tests\setup.bundle.js
[../node_modules/@angular/core/fesm5/core.js] ./node_modules/@angular/core/fesm5/core.js 1.18 MiB {vendor} [built]
[../node_modules/@angular/core/fesm5/testing.js] ./node_modules/@angular/core/fesm5/testing.js 110 KiB {vendor} [built]
[../node_modules/@nativescript/angular/platform-common.js] ./node_modules/@nativescript/angular/platform-common.js 13.8 KiB {vendor} [built]
[../node_modules/@nativescript/angular/platform-providers.js] ./node_modules/@nativescript/angular/platform-providers.js 4.42 KiB {vendor} [built]
[../node_modules/@nativescript/angular/platform.js] ./node_modules/@nativescript/angular/platform.js 2.24 KiB {vendor} [built]
[../node_modules/@nativescript/angular/testing/index.js] ./node_modules/@nativescript/angular/testing/index.js 1.67 KiB {vendor} [built]
[../node_modules/@nativescript/angular/testing/src/nativescript_test_component_renderer.js] ./node_modules/@nativescript/angular/testing/src/nativescript_test_component_renderer.js 1.21 KiB {vendor} [built]
[../node_modules/@nativescript/angular/testing/src/util.js] ./node_modules/@nativescript/angular/testing/src/util.js 7.63 KiB {vendor} [built]
[../node_modules/@nativescript/angular/zone-js/testing.jasmine.js] ./node_modules/@nativescript/angular/zone-js/testing.jasmine.js 228 bytes {vendor} [built]
[./app/item/item.service.ts] ./src/app/item/item.service.ts 1.59 KiB {src\tests\item.service} {src\tests\items.component} [built]
[./app/item/items.component.ts] ./src/app/item/items.component.ts 733 bytes {src\tests\items.component} [built]
[./tests/example.ts] ./src/tests/example.ts 162 bytes {src\tests\example} [built]
[./tests/item.service.ts] ./src/tests/item.service.ts 430 bytes {src\tests\item.service} [built]
[./tests/items.component.ts] ./src/tests/items.component.ts 877 bytes {src\tests\items.component} [built]
[./tests/setup.ts] ./src/tests/setup.ts 134 bytes {src\tests\setup} [built]
+ 591 hidden modules
i 「wdm」: Compiled successfully.
16 09 2020 12:03:44.617:WARN [karma]: No captured browser, open http://localhost:9877/
16 09 2020 12:03:44.633:INFO [karma-server]: Karma v4.4.1 server started at http://0.0.0.0:9877/
16 09 2020 12:03:44.633:INFO [launcher]: Launching browsers android with concurrency unlimited
16 09 2020 12:03:44.666:INFO [launcher]: Starting browser NativeScript Unit Test Runner
Preparing project...
File change detected. Starting incremental webpack compilation...
webpack is watching the files…
Hash: f3ade68811e5c01b58be
Version: webpack 4.27.1
Time: 5982ms
Built at: 2020-09-16 12:03:52 PM
Asset Size Chunks Chunk Names
bundle.js 31.1 KiB bundle [emitted] bundle
package.json 112 bytes [emitted]
runtime.js 13.9 KiB runtime [emitted] runtime
tns-java-classes.js 0 bytes [emitted]
vendor.js 16.3 MiB vendor [emitted] vendor
Entrypoint bundle = runtime.js vendor.js bundle.js
[../$$_lazy_route_resource lazy recursive] ../$$_lazy_route_resource lazy namespace object 160 bytes {bundle} [built]
[../node_modules/nativescript-unit-test-runner/app sync recursive (?<!\bApp_Resources\b.*)(?<!\.\/\btests\b\/.*?)\.(xml|css|js|kt|(?<!\.d\.)ts|(?<!\b_[\w-]*\.)scss)$] ../node_modules/nativescript-unit-test-runner/app sync (?<!\bApp_Resources\b.*)(?<!\.\/\btests\b\/.*?)\.(xml|css|js|kt|(?<!\.d\.)ts|(?<!\b_[\w-]*
\.)scss)$ 632 bytes {bundle} [built]
[./ sync recursive tests\/.*\.(ts|js)] . sync tests\/.*\.(ts|js) 263 bytes {bundle} [built]
[./app/item/item.service.ts] 1.63 KiB {bundle} [built]
[./app/item/items.component.ts] 396 bytes {bundle} [built]
[./main.ts] 1.1 KiB {bundle} [built]
[./package.json] 107 bytes {bundle} [optional] [built]
[./tests/example.ts] 162 bytes {bundle} [optional] [built]
[./tests/item.service.ts] 430 bytes {bundle} [optional] [built]
[./tests/items.component.ts] 877 bytes {bundle} [optional] [built]
[./tests/setup.ts] 134 bytes {bundle} [optional] [built]
+ 621 hidden modules
Webpack compilation complete. Watching for file changes.
Webpack build done!
Project successfully prepared (android)
Successfully transferred bundle.js on device d123a500.
Restarting application on device d123a500...
16 09 2020 12:03:57.242:INFO [NativeScript / 29 (10; IN2023)]: Connected on socket BOhHVyPD6SsFebx8AAAA with id NativeScriptUnit-6768
Successfully synced application org.nativescript.UnitTesting on device d123a500.
NativeScript / 29 (10; IN2023) ItemsComponent Test should be defined FAILED
error properties: Object({ originalStack: 'Error: Can't resolve all parameters for ApplicationModule: (?).
at ZoneAwareError (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:85903:33)
at syntaxError (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:9475:17)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getDependenciesMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28631:35)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getTypeMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28523:26)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28391:24)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/com ...
Error: Can't resolve all parameters for ApplicationModule: (?).
at ZoneAwareError (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:85903:33)
at syntaxError (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:9475:17)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getDependenciesMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28631:35)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getTypeMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28523:26)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28391:24)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleSummary (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28201:35)
at file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28288:55
at <Jasmine>
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28266:49)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleSummary (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28201:35)
at file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28288:55
at <Jasmine>
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28266:49)
at JitCompiler.push.../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._loadModules (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:34433:51)
at JitCompiler.push.../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndAllComponents (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:34421:36)
error properties: Object({ originalStack: 'Error: Can't resolve all parameters for ApplicationModule: (?).
at ZoneAwareError (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:85903:33)
at syntaxError (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:9475:17)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getDependenciesMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28631:35)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getTypeMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28523:26)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28391:24)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/com ...
Error: Can't resolve all parameters for ApplicationModule: (?).
at ZoneAwareError (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:85903:33)
at syntaxError (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:9475:17)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getDependenciesMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28631:35)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getTypeMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28523:26)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28391:24)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleSummary (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28201:35)
at file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28288:55
at <Jasmine>
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28266:49)
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleSummary (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28201:35)
at file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28288:55
at <Jasmine>
at CompileMetadataResolver.push.../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:28266:49)
at JitCompiler.push.../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._loadModules (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:34433:51)
at JitCompiler.push.../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndAllComponents (file:///data/data/org.nativescript.UnitTesting/files/app/vendor.js:34421:36)
NativeScript / 29 (10; IN2023): Executed 5 of 5 (1 FAILED) (0.092 secs / 0.012 secs)
TOTAL: 1 FAILED, 4 SUCCESS
JS: NSUTR: fetching http://10.10.10.250:9877/context.json
JS: NSUTR: fetching http://172.21.208.1:9877/context.json
JS: NSUTR: fetching http://192.168.1.91:9877/context.json
JS: NSUTR: fetching http://192.168.56.1:9877/context.json
JS: NSUTR: fetching http://127.0.0.1:9877/context.json
JS: NSUTR: found karma at 192.168.1.91
JS: NSUTR: connecting to karma at http://192.168.1.91:9877
JS: NSUTR: successfully connected to karma
JS: getFrameById() is deprecated. Use Frame.getFrameById() instead.
JS: NSUTR: downloading http://192.168.1.91:9877/context.json
JS: NSUTR: eval script /base/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?fbc7eaf339ea249d8c912b258548d4e7b4dc180c
JS: NSUTR: eval script /base/node_modules/karma-jasmine/lib/boot.js?760d54bbca4f739f1f8b252c1636d76201cc4e88
JS: NSUTR: eval script /base/node_modules/karma-jasmine/lib/adapter.js?f693fb2743611cfdd0e82f7adbb709f510583603
JS: NSUTR: eval script /base/src/tests/example.bundle.js?c90d47fe20565ea5946bb869444e23f7780dbee6
JS: NSUTR: eval script /base/src/tests/item.service.bundle.js?28f45223f86d9681ae9d6923a2587254c4527866
JS: NSUTR: eval script /base/src/tests/items.component.bundle.js?ba8a69c5a4e8a138634a38a3d02c2efb5b49f794
JS: NSUTR: eval script /base/src/tests/setup.bundle.js?64a7258273dc1e95ccf16770a4b50ef47f6af080
JS: NSUTR: beginning test run
NativeScript / 29 (10; IN2023) ERROR
DisconnectedClient disconnected from CONNECTED state (transport error)
NativeScript / 29 (10; IN2023): Executed 5 of 5 (1 FAILED) (0.092 secs / 0.012 secs)
JS: NSUTR: completed test run.
JS: NSUTR: completeAck
To reproduce:
# git log -n 1
commit 86134c5baf509b8e9b805ad70fcb58bbb03f80ca (HEAD -> master, origin/master, origin/HEAD)
Author: Aubrey Quinn <xxxx>
Date: Wed Mar 18 11:24:36 2020 +0000
Update items.component.ts
alternative ItemsComponent Test written
#git remote -v
origin https://github.com/aubrey-fowler/NativeScriptUnitTests.git (fetch)
origin https://github.com/aubrey-fowler/NativeScriptUnitTests.git (push)
#git diff
diff --git a/src/tests/items.component.ts b/src/tests/items.component.ts
index 7904be5..4833001 100644
--- a/src/tests/items.component.ts
+++ b/src/tests/items.component.ts
@@ -7,7 +7,7 @@ import {
nsTestBedRender
} from 'nativescript-angular/testing';
-xdescribe('ItemsComponent Test', () => {
+describe('ItemsComponent Test', () => {
beforeEach(nsTestBedBeforeEach([ItemsComponent]));
afterEach(nsTestBedAfterEach(false));
@@ -34,4 +34,4 @@ describe('ItemsComponent Test', () => {
expect(component).toBeTruthy();
});
-});
\ No newline at end of file
+});
Sadly my project runs into the exact same issues about setting up the UnitTests, thats why its impossible to use them at the moment, which is pretty bad because some stuff needs to be covered with it..
I'm writing an app with NativeScript 6+ and Angular 8+.
I'm trying to write some unit tests and get them up and running.
I have read the documentation on unit testing: https://docs.nativescript.org/tooling/testing/testing
I followed the directions there for setting up the tests and using TestBed. My tests are not working and throwing errors.
Here is my repository: https://github.com/aubrey-fowler/NativeScriptUnitTests
Questions:
Errors:
no reachable hosts
on my Android phone
code snippet: