fuse-box / angular2-example

43 stars 13 forks source link

Testing still failing #20

Open rajinder-yadav opened 7 years ago

rajinder-yadav commented 7 years ago

On Linux I am seeing this error:

> fusebox-angular@1.0.0 test /tmp/angular2-example                                                                           
> cross-env TS_NODE_PROJECT=./src/tsconfig.mocha.json mocha --opts ./test/mocha.opts -G                                      

module.js:472                                                                                                                
    throw err;                                                                                                               
    ^                                                                                                                        

Error: Cannot find module 'jsdom'  

If I correct mocha.shim.js by this

var jsdom = require('jsdom-no-contextify')

I see a failing test

$ npm t                                                                                             

> fusebox-angular@1.0.0 test /tmp/angular2-example                                                                           
> cross-env TS_NODE_PROJECT=./src/tsconfig.mocha.json mocha --opts ./test/mocha.opts -G                                      

  TodoListComponent                                                                                                          
    1) calls service to get todos                                                                                            

  0 passing (336ms)                                                                                                          
  1 failing                                                                                                                  

  1) TodoListComponent calls service to get todos:                                                                           
     Error: Error in ./TodoListComponent class TodoListComponent - inline template:16:60 caused by: Cannot read property 'add' of undefined                                                                                                               
      at ViewWrappedError.ZoneAwareError (/tmp/angular2-example/node_modules/zone.js/dist/zone.js:958:33)                    
      at ViewWrappedError.BaseError [as constructor] (/tmp/angular2-example/node_modules/@angular/core/bundles/core.umd.js:1239:20)                                                                                                                       
      at ViewWrappedError.WrappedError [as constructor] (/tmp/angular2-example/node_modules/@angular/core/bundles/core.umd.js:1297:20)                                                                                                                    
      at new ViewWrappedError (/tmp/angular2-example/node_modules/@angular/core/bundles/core.umd.js:6167:20)                 
      at CompiledTemplate.proxyViewClass.DebugAppView._rethrowWithContext (/tmp/angular2-example/node_modules/@angular/core/bundles/core.umd.js:12385:27)                                                                                                 
      at CompiledTemplate.proxyViewClass.DebugAppView.detectChanges (/tmp/angular2-example/node_modules/@angular/core/bundles/core.umd.js:12358:22)                                                                                                       
      at CompiledTemplate.proxyViewClass.AppView.internalDetectChanges (/tmp/angular2-example/node_modules/@angular/core/bundles/core.umd.js:12193:22)
      at CompiledTemplate.proxyViewClass.View_TodoListComponent_Host0.detectChangesInternal (/DynamicTestModule/TodoListComponent/host.ngfactory.js:29:19)
      at CompiledTemplate.proxyViewClass.AppView.detectChanges (/tmp/angular2-example/node_modules/@angular/core/bundles/core.umd.js:12208:18)
      at CompiledTemplate.proxyViewClass.DebugAppView.detectChanges (/tmp/angular2-example/node_modules/@angular/core/bundles/core.umd.js:12355:48)
      at ViewRef_.detectChanges (/tmp/angular2-example/node_modules/@angular/core/bundles/core.umd.js:9377:24)
      at ComponentFixture._tick (/tmp/angular2-example/node_modules/@angular/core/bundles/core-testing.umd.js:196:36)
      at /tmp/angular2-example/node_modules/@angular/core/bundles/core-testing.umd.js:210:53
      at ZoneDelegate.invoke (/tmp/angular2-example/node_modules/zone.js/dist/zone.js:330:26)
      at Object.onInvoke (/tmp/angular2-example/node_modules/@angular/core/bundles/core.umd.js:3980:41)
      at ZoneDelegate.invoke (/tmp/angular2-example/node_modules/zone.js/dist/zone.js:329:32)
      at Zone.run (/tmp/angular2-example/node_modules/zone.js/dist/zone.js:126:43)
      at NgZone.run (/tmp/angular2-example/node_modules/@angular/core/bundles/core.umd.js:3849:66)
      at ComponentFixture.detectChanges (/tmp/angular2-example/node_modules/@angular/core/bundles/core-testing.umd.js:210:29)
      at Context.it (/tmp/angular2-example/src/todo/todo-list.component.spec.ts:53:17)
      at callFn (/tmp/angular2-example/node_modules/mocha/lib/runnable.js:345:21)
      at Test.Runnable.run (/tmp/angular2-example/node_modules/mocha/lib/runnable.js:337:7)
      at Runner.runTest (/tmp/angular2-example/node_modules/mocha/lib/runner.js:444:10)
      at /tmp/angular2-example/node_modules/mocha/lib/runner.js:550:12
      at next (/tmp/angular2-example/node_modules/mocha/lib/runner.js:361:14)
      at /tmp/angular2-example/node_modules/mocha/lib/runner.js:371:7
      at next (/tmp/angular2-example/node_modules/mocha/lib/runner.js:295:14)
      at /tmp/angular2-example/node_modules/mocha/lib/runner.js:334:7
      at done (/tmp/angular2-example/node_modules/mocha/lib/runnable.js:295:5)
      at callFn (/tmp/angular2-example/node_modules/mocha/lib/runnable.js:363:7)
      at Hook.Runnable.run (/tmp/angular2-example/node_modules/mocha/lib/runnable.js:337:7)
      at next (/tmp/angular2-example/node_modules/mocha/lib/runner.js:309:10)
      at /tmp/angular2-example/node_modules/mocha/lib/runner.js:334:7
      at done (/tmp/angular2-example/node_modules/mocha/lib/runnable.js:295:5)
      at callFn (/tmp/angular2-example/node_modules/mocha/lib/runnable.js:363:7)
      at Hook.Runnable.run (/tmp/angular2-example/node_modules/mocha/lib/runnable.js:337:7)
      at next (/tmp/angular2-example/node_modules/mocha/lib/runner.js:309:10)
      at Immediate.<anonymous> (/tmp/angular2-example/node_modules/mocha/lib/runner.js:339:5)
      at runCallback (timers.js:651:20)
      at tryOnImmediate (timers.js:624:5)
      at processImmediate [as _immediateCallback] (timers.js:596:5)
ojacquemart commented 7 years ago

I confirm. jsdom is missing.

    "js-dom": "^0.0.1",
    "jsdom": "^9.9.1",

After cleaning node_modules & running npm install again, I have

TypeError: Unable to require `.d.ts` file.
This is usually the result of a faulty configuration or import

Stranger things.

nchanged commented 7 years ago

I have added jsdom + travis. Let's keep pushing guys! Thanks a lot!

nchanged commented 7 years ago

The tests don't exit and travis can't just figure it out ... Any idea?

rajinder-yadav commented 7 years ago

@ojacquemart jsdom has a problem on Linux, with respect to contextify, I was getting errors. So I submitted a fix, seem like someone reverted back to require jsdom in mocha.shim.js?

See Issue: https://github.com/fuse-box/angular2-example/issues/13 and PR: https://github.com/fuse-box/angular2-example/pull/16/files

ojacquemart commented 7 years ago

@rajinder-yadav I am on linux too. No probs with jsdom. If I switch to jsdom-no-contextify in the mocha-shim file, I got the following error:

  1) TodoListComponent calls service to get todos:
     Error: Error in ./TodoListComponent class TodoListComponent - inline template:16:60 caused by: Cannot read property 'add' of undefined
      at ViewWrappedError.Error (native)
      at ViewWrappedError.ZoneAwareError (/home/olivier/dev/workspaces/angular2/angular2-example/node_modules/zone.js/dist/zone.js:958:33)

My node version: 6.9.2

In fact, the tests pass on the master. I had a strange directory making it fail previously. I test

@nchanged We should add a specific script and a specifc mocha opts file, for travis.

Without the option --watch src/**/!(main)*.ts in the mocha.opts, the tests exit.

rajinder-yadav commented 7 years ago

@ojacquemart My node and npm are more recent, could be the reason I see errors?

~: $ node -v
v7.4.0
~: $ npm -v
4.2.0

[Update] Confirmed it's versioning issues. If I use the following version, everything works fire.

angular2-example: master$ node -v
v6.9.2
angular2-example: master$ npm -v
3.10.9

Not sure what should be done? either open bug with upstream or find a fix.

rajinder-yadav commented 7 years ago

I just updated to node 7.5.0 and the everything is workings off master, the test passing!

ojacquemart commented 7 years ago

No idea why it could fail on node 7.4. Great :+1:

RPDeshaies commented 7 years ago

I just downloaded the latest version and I'm still having issues

TSError: ⨯ Unable to compile TypeScript
src\todo\todo-list.component.spec.ts (19,1): Cannot find name 'describe'. (2304)
src\todo\todo-list.component.spec.ts (23,5): Cannot find name 'beforeEach'. (2304)
src\todo\todo-list.component.spec.ts (27,5): Cannot find name 'afterEach'. (2304)
src\todo\todo-list.component.spec.ts (31,5): Cannot find name 'beforeEach'. (2304)
src\todo\todo-list.component.spec.ts (51,5): Cannot find name 'it'. (2304)
src\todo\todo-list.component.spec.ts (58,5): Cannot find name 'it'. (2304)
src\todo\todo-list.component.spec.ts (67,5): Cannot find name 'it'. (2304)
src\todo\todo-list.component.spec.ts (73,5): Cannot find name 'it'. (2304)
src\todo\todo-list.component.spec.ts (86,5): Cannot find name 'it'. (2304)
src\todo\todo-list.component.spec.ts (93,5): Cannot find name 'it'. (2304)
src\todo\todo-list.component.spec.ts (107,5): Cannot find name 'it'. (2304)
src\todo\todo-list.component.spec.ts (116,5): Cannot find name 'it'. (2304)

On Windows 7

RPDeshaies commented 7 years ago

But when I declare the variables, everything is OK :

declare const describe: any;
declare const it: any;
devmondo commented 7 years ago

@RPDeshaies maybe you need to place your tsconfig in the root of your application?

ojacquemart commented 7 years ago

@RPDeshaies Could you try to add "types": [ "node", "mocha", "chai" ] in the tsconfig.mocha.json?

RPDeshaies commented 7 years ago

@ojacquemart not working

image

@devmondo just tried and I'm still getting the errors

tolemac commented 7 years ago

The same problem here:

throw new TSError(formatDiagnostics(diagnosticList, cwd, ts, lineOffset))
                ^
TSError: ⨯ Unable to compile TypeScript
src\todo\todo-list.component.spec.ts (19,1): Cannot find name 'describe'. (2304)
src\todo\todo-list.component.spec.ts (23,5): Cannot find name 'beforeEach'. (2304)
src\todo\todo-list.component.spec.ts (27,5): Cannot find name 'afterEach'. (2304)
src\todo\todo-list.component.spec.ts (31,5): Cannot find name 'beforeEach'. (2304)
src\todo\todo-list.component.spec.ts (51,5): Cannot find name 'it'. (2304)
src\todo\todo-list.component.spec.ts (58,5): Cannot find name 'it'. (2304)
src\todo\todo-list.component.spec.ts (67,5): Cannot find name 'it'. (2304)
src\todo\todo-list.component.spec.ts (73,5): Cannot find name 'it'. (2304)
src\todo\todo-list.component.spec.ts (86,5): Cannot find name 'it'. (2304)
src\todo\todo-list.component.spec.ts (93,5): Cannot find name 'it'. (2304)
src\todo\todo-list.component.spec.ts (107,5): Cannot find name 'it'. (2304)
src\todo\todo-list.component.spec.ts (116,5): Cannot find name 'it'. (2304)