Skip to content
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

Karma crash after updating code #77

Closed
mbakker96 opened this issue Apr 18, 2016 · 9 comments
Closed

Karma crash after updating code #77

mbakker96 opened this issue Apr 18, 2016 · 9 comments
Labels

Comments

@mbakker96
Copy link
Contributor

After I change something in my code while I run npm run test.watch and npm run karma in 2 different terminals the test shows no tests any more.

This is what I do:

  1. Run npm run test.watch
  2. Run npm run karma (First time the test runs perfect)
  3. I change something in the test like expect(clickerApp['pages'].length).toEqual(3);
  4. I see that the test is running again and removed all my .js test files. and runned the test again without any tests so I get a empty table
npm run karma

> clicker@ karma /Users/martijnbakker/projects/clicker
> gulp --gulpfile test/gulpfile.ts --cwd ./ test.karma.debug

[15:42:44] Requiring external module ts-node/register
[15:42:48] sourced Ionic's gulpfile @ /Users/martijnbakker/projects/clicker/gulpfile.js
[15:42:48] Using gulpfile ~/projects/clicker/test/gulpfile.ts
[15:42:48] Starting 'test.karma.debug'...
18 04 2016 15:42:49.731:WARN [karma]: No captured browser, open http://localhost:9876/
18 04 2016 15:42:49.742:INFO [karma]: Karma v0.13.22 server started at http://localhost:9876/
18 04 2016 15:42:49.746:INFO [launcher]: Starting browser Chrome
18 04 2016 15:42:50.996:INFO [Chrome 49.0.2623 (Mac OS X 10.11.2)]: Connected on socket /#XqiZQaZOP_vpedOJAAAA with id 72607031

START:
  Click
    ✔ initialises with defaults
    ✔ initialises with overrides
  Clicker
    ✔ initialises with the correct name
  Utils
    ✔ resets a control
  ClickerApp
    ✖ initialises with two possible pages
    ✔ initialises with a root page
    ✔ initialises with an app
    ✔ opens a page
  ClickerButton
    ✔ initialises
    ✔ displays the clicker name and count
    ✔ does a click
  ClickerForm
    ✔ initialises
    ✔ passes new clicker through to service
    ✔ doesn't try to add a clicker with no name
  ClickerList
    ✔ initialises
  Clickers
    ✔ initialises with empty clickers
    ✔ creates an instance of SqlStorage
    ✔ has empty ids with no storage
    ✔ has empty clickers with no storage
    ✔ can initialise a clicker from string
    ✔ returns undefined for a bad id
    ✔ adds a new clicker with the correct name
    ✔ removes a clicker by id
    ✔ does a click
    ✔ loads IDs from storage
    ✔ loads clickers from storage

Finished in 0.707 secs / 0.628 secs

SUMMARY:
✔ 25 tests completed
✖ 1 test failed

FAILED TESTS:
  ClickerApp
    ✖ initialises with two possible pages
      Chrome 49.0.2623 (Mac OS X 10.11.2)
    Expected 2 to equal 3.
        at Object.eval (/Users/martijnbakker/projects/clicker/www/build/test/app.spec.js:26:48)

--------------------------------|----------|----------|----------|----------|----------------|
File                            |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
--------------------------------|----------|----------|----------|----------|----------------|
 test/                          |    89.74 |    48.39 |       80 |    94.29 |                |
  app.js                        |    89.66 |    48.28 |    85.71 |       96 |              5 |
  testUtils.js                  |       90 |       50 |    66.67 |       90 |              8 |
 test/components/clickerButton/ |       85 |    48.28 |      100 |    93.75 |                |
  clickerButton.js              |       85 |    48.28 |      100 |    93.75 |              5 |
 test/components/clickerForm/   |    90.32 |    51.61 |      100 |     96.3 |                |
  clickerForm.js                |    90.32 |    51.61 |      100 |     96.3 |              5 |
 test/models/                   |      100 |      100 |      100 |      100 |                |
  click.js                      |      100 |      100 |      100 |      100 |                |
  clicker.js                    |      100 |      100 |      100 |      100 |                |
 test/pages/clickerList/        |    86.96 |    48.28 |      100 |    94.74 |                |
  clickerList.js                |    86.96 |    48.28 |      100 |    94.74 |              5 |
 test/pages/page2/              |    82.35 |    48.28 |       75 |    92.31 |                |
  page2.js                      |    82.35 |    48.28 |       75 |    92.31 |              5 |
 test/services/                 |    93.75 |    51.61 |       90 |    96.59 |                |
  clickers.js                   |     96.3 |    51.61 |      100 |    98.65 |              5 |
  utils.js                      |       80 |      100 |       40 |    85.71 |            6,8 |
--------------------------------|----------|----------|----------|----------|----------------|
All files                       |    91.34 |    50.54 |    91.18 |    96.02 |                |
--------------------------------|----------|----------|----------|----------|----------------|


HERE I CHANGED APP.SPEC.TS


18 04 2016 15:43:02.247:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/app.spec.js".
18 04 2016 15:43:02.258:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/app.stub.js".
18 04 2016 15:43:02.267:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/testUtils.js".
18 04 2016 15:43:02.276:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/app.js".
18 04 2016 15:43:02.286:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/models/click.js".
18 04 2016 15:43:02.295:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/services/clickers.spec.js".
18 04 2016 15:43:02.305:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/components/clickerForm/clickerForm.js".
18 04 2016 15:43:02.314:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/models/clicker.js".
18 04 2016 15:43:02.324:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/gulpfile.js".
18 04 2016 15:43:02.333:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/services/clickers.js".
18 04 2016 15:43:02.342:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/pages/page2/page2.js".
18 04 2016 15:43:02.353:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/components/clickerButton/clickerButton.spec.js".
18 04 2016 15:43:02.360:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/models/click.spec.js".
18 04 2016 15:43:02.368:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/components/clickerButton/clickerButton.js".
18 04 2016 15:43:02.376:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/app.e2e.js".
18 04 2016 15:43:02.385:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/pages/clickerList/clickerList.e2e.js".
18 04 2016 15:43:02.394:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/services/utils.js".
18 04 2016 15:43:02.406:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/components/clickerForm/clickerForm.spec.js".
18 04 2016 15:43:02.424:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/pages/clickerList/clickerList.js".
18 04 2016 15:43:02.433:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/models/clicker.spec.js".
18 04 2016 15:43:02.440:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/pages/clickerList/clickerList.spec.js".
18 04 2016 15:43:02.447:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/services/utils.spec.js".
18 04 2016 15:43:02.454:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/config.js".
18 04 2016 15:43:02.461:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/pages/page2/page2.e2e.js".

===================================================================================================================================================================================================================================

START:

Finished in 0.006 secs / 0 secs

SUMMARY:
✔ 0 tests completed
----------|----------|----------|----------|----------|----------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
----------|----------|----------|----------|----------|----------------|
----------|----------|----------|----------|----------|----------------|
All files |      100 |      100 |      100 |      100 |                |
----------|----------|----------|----------|----------|----------------|
@lathonez
Copy link
Owner

Interesting, thanks for raising.

I'm going to be merging some fairly major changes in over the next few days, I'll leave this open until after that is done and test it then.

@lathonez lathonez added the bug label Apr 18, 2016
@mbakker96
Copy link
Contributor Author

It looks like he deletes all tests and not created it again. so it does no tests anymore

@lathonez
Copy link
Owner

Can you pull latest and see if you can replicate?

@mbakker96
Copy link
Contributor Author

@lathonez this what I get now after following the README:

Mac-mini:clicker martijnbakker$ npm run karma

> clicker@1.0.0 karma /Users/martijnbakker/projects/clicker
> gulp --gulpfile test/gulpfile.ts --cwd ./ karma-debug

[15:26:51] Requiring external module ts-node/register
[15:27:12] sourced Ionic's gulpfile @ /Users/martijnbakker/projects/clicker/gulpfile.js
[15:27:12] Using gulpfile ~/projects/clicker/test/gulpfile.ts
[15:27:12] Starting 'karma-debug'...
20 04 2016 15:27:16.443:WARN [karma]: No captured browser, open http://localhost:9876/
20 04 2016 15:27:16.455:WARN [karma]: Port 9876 in use
20 04 2016 15:27:16.456:INFO [karma]: Karma v0.13.22 server started at http://localhost:9877/
20 04 2016 15:27:16.479:INFO [launcher]: Starting browser Chrome
20 04 2016 15:27:19.338:INFO [Chrome 49.0.2623 (Mac OS X 10.11.2)]: Connected on socket /#cx6D1DKAh8uBev-aAAAA with id 12901630

START:
  ClickerApp
    ✔ initialises with two possible pages
    ✔ initialises with a root page
    ✔ initialises with an app
    ✔ opens a page
ERROR: 'EXCEPTION: Failed to load build/app.html'
ERROR: 'EXCEPTION: Error: Uncaught (in promise): Failed to load build/app.html'
ERROR: 'STACKTRACE:'
ERROR: 'Error: Uncaught (in promise): Failed to load build/app.html
    at resolvePromise (http://localhost:9877/base/node_modules/angular2/bundles/angular2-polyfills.js?515e45a0cf377eb121bfd453f38a79b8d69bce25:543:32)
    at http://localhost:9877/base/node_modules/angular2/bundles/angular2-polyfills.js?515e45a0cf377eb121bfd453f38a79b8d69bce25:579:18
    at ZoneDelegate.invokeTask (http://localhost:9877/base/node_modules/angular2/bundles/angular2-polyfills.js?515e45a0cf377eb121bfd453f38a79b8d69bce25:365:38)
    at Object.NgZoneImpl.inner.inner.fork.onInvokeTask (http://localhost:9877/base/www/build/test/test.bundle.js?0d9bd470922e5c740bb28c70abb661451d98577f:9:1792460)
    at ZoneDelegate.invokeTask (http://localhost:9877/base/node_modules/angular2/bundles/angular2-polyfills.js?515e45a0cf377eb121bfd453f38a79b8d69bce25:364:43)
    at Zone.runTask (http://localhost:9877/base/node_modules/angular2/bundles/angular2-polyfills.js?515e45a0cf377eb121bfd453f38a79b8d69bce25:263:48)
    at drainMicroTaskQueue (http://localhost:9877/base/node_modules/angular2/bundles/angular2-polyfills.js?515e45a0cf377eb121bfd453f38a79b8d69bce25:482:36)
    at XMLHttpRequest.ZoneTask.invoke (http://localhost:9877/base/node_modules/angular2/bundles/angular2-polyfills.js?515e45a0cf377eb121bfd453f38a79b8d69bce25:434:22)'
ERROR: 'Unhandled Promise rejection:', 'Failed to load build/app.html', '; Zone:', 'angular', '; Task:', 'Promise.then', '; Value:', 'Failed to load build/app.html'
ERROR: Error{rejection: 'Failed to load build/app.html', promise: ZoneAwarePromise{__zone_symbol__state: 0, __zone_symbol__value: 'Failed to load build/app.html'}, zone: Zone{_properties: Object{isAngularZone: ...}, _parent: Zone{_properties: ..., _parent: ..., _name: ..., _zoneDelegate: ...}, _name: 'angular', _zoneDelegate: ZoneDelegate{_taskCounts: ..., zone: ..., _parentDelegate: ..., _forkZS: ..., _forkDlgt: ..., _interceptZS: ..., _interceptDlgt: ..., _invokeZS: ..., _invokeDlgt: ..., _handleErrorZS: ..., _handleErrorDlgt: ..., _scheduleTaskZS: ..., _scheduleTaskDlgt: ..., _invokeTaskZS: ..., _invokeTaskDlgt: ..., _cancelTaskZS: ..., _cancelTaskDlgt: ..., _hasTaskZS: ..., _hasTaskDlgt: ...}}, task: ZoneTask{type: 'microTask', zone: Zone{_properties: ..., _parent: ..., _name: ..., _zoneDelegate: ...}, source: 'Promise.then', data: Object{__creationTrace__: ...}, scheduleFn: undefined, cancelFn: null, callback: function () { ... }, invoke: function () { ... }}}
ERROR: 'Unhandled Promise rejection:', 'Failed to load build/app.html', '; Zone:', '<root>', '; Task:', 'Promise.then', '; Value:', 'Failed to load build/app.html'
ERROR: Error{rejection: 'Failed to load build/app.html', promise: ZoneAwarePromise{__zone_symbol__state: 0, __zone_symbol__value: 'Failed to load build/app.html'}, zone: Zone{_properties: Object{}, _parent: null, _name: '<root>', _zoneDelegate: ZoneDelegate{_taskCounts: ..., zone: ..., _parentDelegate: ..., _forkZS: ..., _forkDlgt: ..., _interceptZS: ..., _interceptDlgt: ..., _invokeZS: ..., _invokeDlgt: ..., _handleErrorZS: ..., _handleErrorDlgt: ..., _scheduleTaskZS: ..., _scheduleTaskDlgt: ..., _invokeTaskZS: ..., _invokeTaskDlgt: ..., _cancelTaskZS: ..., _cancelTaskDlgt: ..., _hasTaskZS: ..., _hasTaskDlgt: ...}}, task: ZoneTask{type: 'microTask', zone: Zone{_properties: ..., _parent: ..., _name: ..., _zoneDelegate: ...}, source: 'Promise.then', data: undefined, scheduleFn: undefined, cancelFn: null, callback: function () { ... }, invoke: function () { ... }}}
ERROR: 'ERROR - An error has occurred inside a promise!'
  ClickerButton
    ✖ initialises
Chrome 49.0.2623 (Mac OS X 10.11.2) ERROR
  Uncaught Failed to load build/components/clickerButton/clickerButton.html
  at /Users/martijnbakker/projects/clicker/node_modules/angular2/bundles/angular2-polyfills.js:267

Finished in 0.115 secs / 0.085 secs

SUMMARY:
✔ 4 tests completed
✖ 1 test failed

FAILED TESTS:
  ClickerButton
    ✖ initialises
      Chrome 49.0.2623 (Mac OS X 10.11.2)
    Expected null not to be null.
        at Object.<anonymous> (/Users/martijnbakker/projects/clicker/www/build/test/test.bundle.js:9:12751)

20 04 2016 15:29:02.619:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/test.bundle.js.map".
20 04 2016 15:29:02.630:INFO [watcher]: Removed file "/Users/martijnbakker/projects/clicker/www/build/test/test.bundle.js".
20 04 2016 15:29:02.638:INFO [watcher]: Changed file "/Users/martijnbakker/projects/clicker/www/build/app.html".

====================================================================================================================

START:
20 04 2016 15:29:02.925:INFO [watcher]: Changed file "/Users/martijnbakker/projects/clicker/www/build/components/clickerButton/clickerButton.html".
20 04 2016 15:29:02.929:INFO [watcher]: Changed file "/Users/martijnbakker/projects/clicker/www/build/components/clickerForm/clickerForm.html".
20 04 2016 15:29:03.022:INFO [watcher]: Changed file "/Users/martijnbakker/projects/clicker/www/build/pages/clickerList/clickerList.html".
20 04 2016 15:29:03.024:INFO [watcher]: Changed file "/Users/martijnbakker/projects/clicker/www/build/pages/page2/page2.html".

Finished in 0.005 secs / 0 secs

SUMMARY:
✔ 0 tests completed

====================================================================================================================

START:

Finished in 0.005 secs / 0 secs

SUMMARY:
✔ 0 tests completed

@marcmeans
Copy link
Contributor

I get this same error under certain circumstances too. I ended up leaving all the tests inside the app.ts file commented out and it works ok.

I thought it might be related to the need to import es6-shim in the app.ts per the upgrade to beta4 instructions for ionic2. If I do that though, I get all kinds of odd behavior with my pages not updating the views until after click events fire and such. Not sure if this is because I'm using the Rx libs in my project and there is something in conflict or what.

@lathonez
Copy link
Owner

Thanks both for the feedback.

That error is caused by test/app.stub.js not getting patched at build time.

Have you followed the migration path at the top of CHANGELOG.md?

Paste the full log output please (including building the tests).
On 21 Apr 2016 07:27, "Marc Means" notifications@github.com wrote:

I get this same error under certain circumstances too. I ended up leaving
all the tests inside the app.ts file commented out and it works ok.

I thought it might be related to the need to import es6-shim in the app.ts
per the upgrade to beta4 instructions for ionic2. If I do that though, I
get all kinds of odd behavior with my pages not updating the views until
after click events fire and such. Not sure if this is because I'm using the
Rx libs in my project and there is something in conflict or what.


You are receiving this because you were mentioned.

Reply to this email directly or view it on GitHub
#77 (comment)

@lathonez
Copy link
Owner

FYI #79 - I've finally figured out how to remove this horrible app stub, but it needs the latest version of Karma.

So when new Karma comes out this will no longer be a thing anyway..

@lathonez
Copy link
Owner

Just for clarity this should be working fine atm.. it is here.

https://github.com/lathonez/clicker/blob/master/test/gulpfile.ts#L118-L135

@lathonez
Copy link
Owner

So, I'm going to close this. If you're facing issues please reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants