Giter Club home page Giter Club logo

Comments (5)

madhavajay avatar madhavajay commented on June 25, 2024

I had to switch the build and test ts config files around due to the way the firebase deploy script expects the build to be tsconfig.json to be the main one, and then added some stuff to get it to transpile the .ts into .js via babel:

"ts-babel": "npx babel src --out-dir lib --extensions '.ts,.tsx'",
"build": "npm run tsc && npm run ts-babel",

So we will need something similar to run before testing which converts the .ts to .js since this is no longer being done by typescript due to the need for babel to get some "advanced features" like the decorators used by the sparkson library.

Also the tests will fail due to the security rules in firestore.rules as well but we can sort that out next once everyone has finished migrating to the REST end point.

from covidwatch-cloud-functions.

miridius avatar miridius commented on June 25, 2024

I don't think the issue is in .ts to .js conversion, it's that in your dependency tree you have multiple libraries (jest and mocha) specifying the same type name differently. I would suggest remove mocha & chai dependencies and just add jest since afaik jest includes its own equivalents of those libraries already.

from covidwatch-cloud-functions.

inmyth avatar inmyth commented on June 25, 2024

@miridius Do you still have this issue ? So on my side I can build and run the test ok. It was just the test script in package.json should point to .mocha/test as it's where the test files are generated.
I included the fix in my PR. Also I wrote my test in mocha but in case there is need to change the test framework we should settle it first.

from covidwatch-cloud-functions.

miridius avatar miridius commented on June 25, 2024

@inmyth I still have the exact same issues.

Steps taken:

  1. Checkout your PR
  2. cd functions
  3. rm -rf node_modules
  4. npm install
  5. npm run build
  6. npm test

Results:

» npm run build

> functions@ build /mnt/c/Users/drolle/Repos/covid19risk/covidwatch-cloud-functions/functions
> npm run tsc && npm run ts-babel


> functions@ tsc /mnt/c/Users/drolle/Repos/covid19risk/covidwatch-cloud-functions/functions
> tsc --build tsconfig.json

../../../../node_modules/@types/jest/index.d.ts:35:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'beforeEach' must be of type 'HookFunction', but here has type 'Lifecycle'.

35 declare var beforeEach: jest.Lifecycle;
               ~~~~~~~~~~

  node_modules/@types/mocha/index.d.ts:2734:13
    2734 declare var beforeEach: Mocha.HookFunction;
                     ~~~~~~~~~~
    'beforeEach' was also declared here.

../../../../node_modules/@types/jest/index.d.ts:37:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'afterEach' must be of type 'HookFunction', but here has type 'Lifecycle'.

37 declare var afterEach: jest.Lifecycle;
               ~~~~~~~~~

  node_modules/@types/mocha/index.d.ts:2752:13
    2752 declare var afterEach: Mocha.HookFunction;
                     ~~~~~~~~~
    'afterEach' was also declared here.

../../../../node_modules/@types/jest/index.d.ts:38:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'describe' must be of type 'SuiteFunction', but here has type 'Describe'.

38 declare var describe: jest.Describe;
               ~~~~~~~~

  node_modules/@types/mocha/index.d.ts:2768:13
    2768 declare var describe: Mocha.SuiteFunction;
                     ~~~~~~~~
    'describe' was also declared here.

../../../../node_modules/@types/jest/index.d.ts:40:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'xdescribe' must be of type 'PendingSuiteFunction', but here has type 'Describe'.

40 declare var xdescribe: jest.Describe;
               ~~~~~~~~~

  node_modules/@types/mocha/index.d.ts:2789:13
    2789 declare var xdescribe: Mocha.PendingSuiteFunction;
                     ~~~~~~~~~
    'xdescribe' was also declared here.

../../../../node_modules/@types/jest/index.d.ts:41:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'it' must be of type 'TestFunction', but here has type 'It'.

41 declare var it: jest.It;
               ~~

  node_modules/@types/mocha/index.d.ts:2803:13
    2803 declare var it: Mocha.TestFunction;
                     ~~
    'it' was also declared here.

../../../../node_modules/@types/jest/index.d.ts:43:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'xit' must be of type 'PendingTestFunction', but here has type 'It'.

43 declare var xit: jest.It;
               ~~~

  node_modules/@types/mocha/index.d.ts:2824:13
    2824 declare var xit: Mocha.PendingTestFunction;
                     ~~~
    'xit' was also declared here.

../../../../node_modules/@types/jest/index.d.ts:44:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'test' must be of type 'TestFunction', but here has type 'It'.

44 declare var test: jest.It;
               ~~~~

  node_modules/@types/mocha/index.d.ts:2817:13
    2817 declare var test: Mocha.TestFunction;
                     ~~~~
    'test' was also declared here.


Found 7 errors.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions@ tsc: `tsc --build tsconfig.json`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the functions@ tsc script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/drolle/.npm/_logs/2020-04-29T09_56_07_312Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions@ build: `npm run tsc && npm run ts-babel`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the functions@ build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/drolle/.npm/_logs/2020-04-29T09_56_07_382Z-debug.log
» npm test                                                                                       1 ↵

> functions@ pretest /mnt/c/Users/drolle/Repos/covid19risk/covidwatch-cloud-functions/functions
> tsc --build tsconfig.test.json

../../../../node_modules/@types/jest/index.d.ts:35:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'beforeEach' must be of type 'HookFunction', but here has type 'Lifecycle'.

35 declare var beforeEach: jest.Lifecycle;
               ~~~~~~~~~~

  node_modules/@types/mocha/index.d.ts:2734:13
    2734 declare var beforeEach: Mocha.HookFunction;
                     ~~~~~~~~~~
    'beforeEach' was also declared here.

../../../../node_modules/@types/jest/index.d.ts:37:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'afterEach' must be of type 'HookFunction', but here has type 'Lifecycle'.

37 declare var afterEach: jest.Lifecycle;
               ~~~~~~~~~

  node_modules/@types/mocha/index.d.ts:2752:13
    2752 declare var afterEach: Mocha.HookFunction;
                     ~~~~~~~~~
    'afterEach' was also declared here.

../../../../node_modules/@types/jest/index.d.ts:38:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'describe' must be of type 'SuiteFunction', but here has type 'Describe'.

38 declare var describe: jest.Describe;
               ~~~~~~~~

  node_modules/@types/mocha/index.d.ts:2768:13
    2768 declare var describe: Mocha.SuiteFunction;
                     ~~~~~~~~
    'describe' was also declared here.

../../../../node_modules/@types/jest/index.d.ts:40:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'xdescribe' must be of type 'PendingSuiteFunction', but here has type 'Describe'.

40 declare var xdescribe: jest.Describe;
               ~~~~~~~~~

  node_modules/@types/mocha/index.d.ts:2789:13
    2789 declare var xdescribe: Mocha.PendingSuiteFunction;
                     ~~~~~~~~~
    'xdescribe' was also declared here.

../../../../node_modules/@types/jest/index.d.ts:41:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'it' must be of type 'TestFunction', but here has type 'It'.

41 declare var it: jest.It;
               ~~

  node_modules/@types/mocha/index.d.ts:2803:13
    2803 declare var it: Mocha.TestFunction;
                     ~~
    'it' was also declared here.

../../../../node_modules/@types/jest/index.d.ts:43:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'xit' must be of type 'PendingTestFunction', but here has type 'It'.

43 declare var xit: jest.It;
               ~~~

  node_modules/@types/mocha/index.d.ts:2824:13
    2824 declare var xit: Mocha.PendingTestFunction;
                     ~~~
    'xit' was also declared here.

../../../../node_modules/@types/jest/index.d.ts:44:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'test' must be of type 'TestFunction', but here has type 'It'.

44 declare var test: jest.It;
               ~~~~

  node_modules/@types/mocha/index.d.ts:2817:13
    2817 declare var test: Mocha.TestFunction;
                     ~~~~
    'test' was also declared here.


Found 7 errors.

npm ERR! Test failed.  See above for more details.

Note: I can get the build working by uninstalling @types/mocha but then of course the tests fail even worse because they need those types. There must be some transitive dependency which includes @types/jest and that is clashing with @types/mocha

from covidwatch-cloud-functions.

miridius avatar miridius commented on June 25, 2024

Never mind I figured it out... @types/jest was in my user node_modules directory... I guess I installed something globally by accident. rm -rf ~/node_modules solved my problem. Sorry! 🤦‍♂️ 😀

from covidwatch-cloud-functions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.