Skip to content

tns test <platform> --watch does not work #2119

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

Closed
cmermingas opened this issue Oct 11, 2016 · 8 comments
Closed

tns test <platform> --watch does not work #2119

cmermingas opened this issue Oct 11, 2016 · 8 comments

Comments

@cmermingas
Copy link

These are the versions of the software that I have:

  • OSX El Capitan
  • tns --version: 2.3.0
  • nativescript-angular: 1.0.1
  • nativescript-unit-test-runner: ^0.3.3
  • tns-core-modules: 2.3.0

This is how I set up the project:

$ tns create my_new_project --ng
$ cd my_new_project
$ tns platform add ios
$ tns platform add android
$ tns test init
    >> Choose jasmine

Without changing any code, I start running tests...

On Android, the tests run and the output ends like this:

$ tns test android --emulator --watch
...
NativeScript / 23 (6.0; Android SDK built for x86) ERROR
  Disconnectedundefined

The tests do not rerun when I make changes. I see that the changes are detected but the tests don't run:

11 10 2016 11:21:04.478:INFO [watcher]: Changed file "/Users/cmermingas/tns_projects/my_new_project/app/tests/example.js".
11 10 2016 11:21:04.732:WARN [karma]: No captured browser, open http://localhost:9876/

If I open a browser, then I get:

11 10 2016 11:22:13.347:INFO [Chrome 53.0.2785 (Mac OS X 10.11.6)]: Connected on socket /#x5V6NG4VxeYe-eglAAAB with id manual-6010
11 10 2016 11:22:21.380:INFO [watcher]: Changed file "/Users/cmermingas/tns_projects/my_new_project/app/tests/example.js".
Chrome 53.0.2785 (Mac OS X 10.11.6) ERROR
  Uncaught ReferenceError: require is not defined
  at app/app.component.js:2

But I understand that I don't need a browser connected here as I do when I am testing a regular web app, correct?

On iOS, I get something similar. The tests run and the output ends like this:

$ tns test ios --emulator --watch
...
NativeScript / 10.0 (10.0; iPhone) ERROR
  Disconnectedundefined

And when I change the code, the tests don't rerun.

@tzraikov
Copy link
Contributor

Currently the watch option is available only when using run, debug and livesync commands.

@cmermingas
Copy link
Author

Cool. The docs are not in sync:

http://docs.nativescript.org/tooling/testing#re-run-tests-on-code-change

screen shot 2016-10-12 at 9 39 50 am

Thank you!

@tzraikov tzraikov removed the feature label Oct 12, 2016
@tzraikov
Copy link
Contributor

@cmermingas Hey, my mistake. The documentation is correct. This is a valid issue. I updated the label.

@tzraikov tzraikov added the bug label Oct 12, 2016
@jeffswitzer
Copy link

I'm also getting the same behavior as @cmermingas when running tns test android --watch under windows 10. Everything else looks to be the same version as @cmermingas is using.

@tzraikov tzraikov added this to the 2.5.0 milestone Nov 29, 2016
@pkoleva pkoleva removed this from the 2.5.0 milestone Jan 4, 2017
@phattranky
Copy link

phattranky commented May 1, 2017

Same issue with @cmermingas, @jeffswitzer on Windows 10 Creator

  • tns --version: 2.5.0
  • nativescript-angular: 1.4.0
  • nativescript-unit-test-runner: ^0.3.4
  • tns-core-modules: 2.5.2

Real Device: Android 5.1 on Galaxy S6

1

@phattranky
Copy link

My Karma config


module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',


    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],


    // list of files / patterns to load in the browser
    files: [
      'app/**/*.ts'
    ],


    // list of files to exclude
    exclude: [
    ],


    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
       'app/**/*.ts': ['typescript', 'coverage']
    },

    typescriptPreprocessor: {
      // options passed to the typescript compiler 
      options: {
        sourceMap: false, // (optional) Generates corresponding .map file. 
        target: 'ES5', // (optional) Specify ECMAScript target version: 'ES3' (default), or 'ES5' 
        module: 'amd', // (optional) Specify module code generation: 'commonjs' or 'amd' 
        noImplicitAny: true, // (optional) Warn on expressions and declarations with an implied 'any' type. 
        noResolve: true, // (optional) Skip resolution and preprocessing. 
        removeComments: true, // (optional) Do not emit comments to output. 
        concatenateOutput: false // (optional) Concatenate and emit output to single file. By default true if module option is omited, otherwise false. 
      },
      // transforming the filenames 
      transformPath: function(path) {
        return path.replace(/\.ts$/, '.js');
      }
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress', 'coverage'],


    // web server port
    port: 9876,


    // enable / disable colors in the output (reporters and logs)
    colors: true,


    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,


    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,


    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: [],

    customLaunchers: {
      android: {
        base: 'NS',
        platform: 'android'
      },
      ios: {
        base: 'NS',
        platform: 'ios'
      },
      ios_simulator: {
        base: 'NS',
        platform: 'ios',
        arguments: ['--emulator']
      }
    },

    coverageReporter: {
      // specify a common output directory
      dir: './coverage',
      reporters: [
          { type: 'lcov', subdir: '.' },
          { type: 'cobertura', subdir: '.' }
      ],
      includeAllSources: true
    },

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: true
  })
}

@phattranky
Copy link

Don't know why, it seems working well on my android emulator

1

@pkoleva pkoleva added feature and removed bug labels May 4, 2017
@dtopuzov dtopuzov changed the title tns test android --watch not rerunning tests tns test <platform> --watch does not work May 4, 2017
@dtopuzov
Copy link
Contributor

dtopuzov commented May 4, 2017

@phattranky it works for you because you have singleRun: true

Closing in favor of #2739

@dtopuzov dtopuzov closed this as completed May 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants