-
-
Notifications
You must be signed in to change notification settings - Fork 241
Default unit testing failing on hello world #1310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @benjlin, |
I also experience this issue within my project and recreated it by following the testing documentation for the downloaded playground application. It seems when invoking the tns test , the client disconnects from the karma server because it cannot compile some javascript. I get the following errors in the console for the browser: |
@pekevski Did you discover the cause of your "uncaught ReferenceError: exports is not defined" |
Same behavior while running "tns test android" for template app (https://github.com/NativeScript/template-drawer-navigation-ng). Any info about this issue? |
Here's what I learned: Use an emulator. When you start your app, (for me it became 'npm start') and Karma asked to open a browser,I was doing so...only to get the exports not defined error. Having an emulator set up within the AVD management portion of Android studio helped. After lots of requests for me to open a browser, karma finally just opens the emulator. However, I was still unable to run tests. I ran into "Zone is undefined" afterwards...which is likely related to the karma.config file set up, although I'm unsure why just yet. Most recommendations I've seen advise not to use Karma on mobile apps, which has been in response to a lack of solution being found. Either way, look at your karma.config file and try using an emulator. |
The initial error that I got was on an emulator, I tried again on the simulator and also found that to be broken, I posted the results from the ios emulator dump and it seems that when my post was edited to read cleaner that was lost. I will try again in the next few days to see if anything has changed with the 4.1.X release as well as downgrade to 3.4.X to see if it is present there |
I ran a clean install of nativescript on a new computer, and when i downloaded the helloWorld template tns create HelloWorld --template nativescript-template-ng-tutorial I found it still broken by default, however after upgrading the typescript dev definition from "~2.7.2" to "2.9.2" i found that the tests work, after successfully running the test, the app crashes but it does successfully run the tests 19 07 2018 13:45:28.905:WARN [karma]: No captured browser, open http://localhost:9876/ |
I had the same problem. I've solved it by doing "tns test init", and picking the mocha framework. Then add the following files to /test folder: test-config.ts . With content: (global).mocha.setup({ import * as chai from 'chai'; test-main.ts . With content: import 'nativescript-angular/zone-js/testing.mocha'; example.ts . With content: import {assert} from './test-config'; describe('A suite', function() { Result: JS: NSUTR: eval script /base/node_modules/chai/chai.js?40e7aa72e9665366bfd82579520de4fb0754dfae |
I ran into this too. This gave the same error as @benjlin reported. After a while I tried renaming |
@m-abs I believe it works because the hooks didn't ran when you are using the new structure but when you changed to the old structure then the hooks will ran and the tests will success |
I've managed to resolve this ( |
Hey folks. I also managed to get the test running by renaming |
After more digging around I found the reason why tests aren't working with The unit-test-runner app has a hardcoded app folder here. However files are in Maybe the solution is to pass the actual |
Even with a new project and latest versions, I had to rename I tried switching between I also needed to add My {
"nativescript": {
"id": "org.nativescript.demo",
"tns-android": {
"version": "5.1.0"
},
"tns-ios": {
"version": "5.1.0"
}
},
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"repository": "<fill-your-repository-here>",
"dependencies": {
"@angular/animations": "~7.2.0",
"@angular/common": "~7.2.0",
"@angular/compiler": "~7.2.0",
"@angular/core": "~7.2.0",
"@angular/forms": "~7.2.0",
"@angular/http": "~7.2.0",
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~7.2.0",
"@nota/nativescript-ngx-tools": "file:../src",
"nativescript-angular": "~7.2.0",
"nativescript-theme-core": "~1.0.4",
"nativescript-unit-test-runner": "^0.4.1",
"reflect-metadata": "~0.1.13",
"rxjs": "^6.4.0",
"tns-core-modules": "~5.1.2",
"zone.js": "^0.8.29",
"typescript": "~3.1.6"
},
"devDependencies": {
"@angular/compiler-cli": "~7.2.0",
"@nativescript/schematics": "~0.5.0",
"@ngtools/webpack": "~7.2.0",
"@types/jasmine": "^3.3.8",
"karma": "4.0.0",
"karma-jasmine": "2.0.1",
"karma-nativescript-launcher": "0.4.0",
"nativescript-dev-typescript": "~0.7.9",
"nativescript-dev-webpack": "~0.19.1",
"prettier": "^1.16.4",
"prettier-check": "^2.0.0",
"tns-platform-declarations": "^5.1.2"
},
"readme": "NativeScript Application"
} Project was created with |
This should be fixed in next version of {N} CLI, so you need
|
I am getting the following error when running karma unit tests:
I am running tns cli v6.5.0 and its failing on the example unit test on a fresh angular NS projection Reproduced by:
|
I added |
@pekevski I have added |
I have the same issue. Running the auto generated example.ts results in an error:
Adding |
When attempting to run unit testing on the default template app it crashes with
Steps to replicate
the same error occurs running both android and ios
I suspect that it is something to do with the default Karma configuration file generated
The text was updated successfully, but these errors were encountered: