Comments (5)
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.
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.
@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.
@inmyth I still have the exact same issues.
Steps taken:
- Checkout your PR
cd functions
rm -rf node_modules
npm install
npm run build
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.
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)
- Schedule cleanup functions
- Add Indexes to Firestore to match queries
- Add GitHub Action to run tests in CI HOT 1
- Add Service Account for Accessing Secure Endpoint
- Add Exposure Notification Configuration Data endpoint
- Design and implement upload token allocation
- For Apple/Google protocol, validate protobuf on upload
- Make constants configurable
- Add pre-submit tests
- Draft a new README
- Use MaxBytesReader to limit request size
- Update Postman file
- Document API endpoints
- Configure Google Cloud Functions to protect /validate
- In /report endpoint, respond with expiration time
- Run go fmt and go vet in Actions
- Add integration tests
- Add integration test: ALLOW_EMPTY_CHALLENGE_SOLUTION
- Disable Actions for draft PRs?
- Use first-class Firestore emulator support once it's available
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from covidwatch-cloud-functions.