lathonez / clicker

Ionic 2 + @angular/cli Seed Project : Angular2 + Typescript + Karma + Protractor + Travis
http://lathonez.com/2018/ionic-2-unit-testing/
MIT License
430 stars 137 forks source link

Transpile failed always #233

Closed qiluo closed 7 years ago

qiluo commented 7 years ago
[16:52:32]  clean finished in 4 ms
[16:52:32]  copy started ...
[16:52:32]  transpile started ...
[16:52:37]  typescript: node_modules/@types/jasmine/index.d.ts, line: 39
            '=' expected.

      L38:      var clock: () => Clock;
      L40:      function any(aclass: any): Any;

[16:52:37]  typescript: node_modules/@types/jasmine/index.d.ts, line: 39
            A parameter initializer is only allowed in a function or constructor implementation.
[16:52:37]  typescript: node_modules/@types/jasmine/index.d.ts, line: 39

      L38:      var clock: () => Clock;
      L40:      function any(aclass: any): Any;

            Cannot find name 'keyof'.

      L38:      var clock: () => Clock;
      L40:      function any(aclass: any): Any;

[16:52:37]  transpile failed

Hi, I followed your tutorial to set up unit test for my project, btw, I'm on ionic 2.1, angular 2.4, however, I always got above error, and also got error when I run npm test

/Users/xxx/Dev/ionic-apps/sidemenu/node_modules/@ngtools/json-schema/src/schema-class-factory.js:48
    constructor(schema, value, ...fallbacks) {
                               ^^^

SyntaxError: Unexpected token ...
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:387:25)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/xxx/Dev/ionic-apps/sidemenu/node_modules/@ngtools/json-schema/src/index.js:3:30)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
npm ERR! Test failed.  See above for more details.

Could anyone please advise?

lathonez commented 7 years ago

Please follow basic debugging steps and report back: https://github.com/lathonez/lathonez.github.io/blob/master/_posts/2017-01-02-ionic-2-unit-testing.markdown#debugging-setup

Google suggests typescript version mismatch.

qiluo commented 7 years ago

Thanks @lathonez , I've solved the first error, still figuring second one. As for first one, we can refer to https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14569

lathonez commented 7 years ago

Nice, thanks for the reference

qiluo commented 7 years ago

Btw, I solved the second error, upgrade node to 6.10.

In fact it was very confusing at this time, the node version, typescript version, angular version, angular-cli version, ionic version, any mismatch may cause error.

lathonez commented 7 years ago

Thanks for replying with your fixes.

As far as I'm aware, node LTS or higher works fine. No one should be using less than LTS anyway.

Unfortunately we're wrestling with two frameworks that have different dependencies. As long as Ionic don't want to maintain any kind of testing framework we are going to have these issues.

However, angular/cli is the last piece of the puzzle that hasn't gone FINAL yet. Hopefully when they go final everything will cease to have breaking changes.